Method and device for processing video signal

ABSTRACT

A method for decoding a video according to the present invention, may comprise determining whether bi-directional intra prediction is applied to a current block, deriving a reference sample of the current block, and when the bi-directional intra prediction is applied to the current block, based on a first reference sample and a second reference sample specified by an intra prediction mode of the current block, obtaining a prediction sample of the current block.

TECHNICAL FIELD

The present invention relates to a method and an apparatus forprocessing video signal.

BACKGROUND ART

Recently, demands for high-resolution and high-quality images such ashigh definition (HD) images and ultra-high definition (UHD) images haveincreased in various application fields. However, higher resolution andquality image data has increasing amounts of data in comparison withconventional image data. Therefore, when transmitting image data byusing a medium such as conventional wired and wireless broadbandnetworks, or when storing image data by using a conventional storagemedium, costs of transmitting and storing increase. In order to solvethese problems occurring with an increase in resolution and quality ofimage data, high-efficiency image encoding/decoding techniques may beutilized.

Image compression technology includes various techniques, including: aninter prediction technique of predicting a pixel value included in acurrent picture from a previous or subsequent picture of the currentpicture; an intra prediction technique of predicting a pixel valueincluded in a current picture by using pixel information in the currentpicture; an entropy encoding technique of assigning a short code to avalue with a high appearance frequency and assigning a long code to avalue with a low appearance frequency; and the like. Image data may beeffectively compressed by using such image compression technology, andmay be transmitted or stored.

In the meantime, with demands for high-resolution images, demands forstereographic image content, which is a new image service, have alsoincreased. A video compression technique for effectively providingstereographic image content with high resolution and ultra-highresolution is being discussed.

DISCLOSURE Technical Problem

An object of the present invention is intended to provide a method andan apparatus for efficiently performing intra prediction for anencoding/decoding target block in encoding/decoding a video signal.

An object of the present invention is intended to provide a method andan apparatus for performing intra prediction using a plurality ofreference samples that is not adjacent to each other inencoding/decoding a video signal.

An object of the present invention is intended to provide a method andan apparatus for performing intra prediction using right and bottomreference samples.

The technical objects to be achieved by the present invention are notlimited to the above-mentioned technical problems. And, other technicalproblems that are not mentioned will be apparently understood to thoseskilled in the art from the following description.

Technical Solution

A method and an apparatus for decoding a video signal according to thepresent invention, may determine whether bi-directional intra predictionis applied to a current block, derive a reference sample of the currentblock; and when the bi-directional intra prediction is applied to thecurrent block, based on a first reference sample and a second referencesample specified by an intra prediction mode of the current block,obtain a prediction sample of the current block.

A method and an apparatus for encoding a video signal according to thepresent invention, may determine whether bi-directional intra predictionis applied to a current block, derive a reference sample of the currentblock; and when the bi-directional intra prediction is applied to thecurrent block, based on a first reference sample and a second referencesample specified by an intra prediction mode of the current block,obtain a prediction sample of the current block.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, the first reference sample may be aleft or top reference sample of the current block, and the secondreference sample may be a right or bottom reference sample of thecurrent block.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, the right reference sample may begenerated by interpolating a bottom right reference sample and a topright reference sample, and the bottom reference sample may be generatedby interpolating the bottom right reference sample and a bottom leftreference sample.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, the first reference sample may beselected by applying the intra prediction mode of the current block in aforward direction, and the second reference sample may be selected byapplying the intra prediction mode of the current block in a reversedirection.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, the prediction sample may beobtained based on a weighted sum operation of a first prediction sampleobtained based on the first reference sample and a second predictionsample obtained based on the second reference sample.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, a weight applied to each of thefirst prediction sample and the second prediction sample may bedetermined based on at least one of a location of a prediction targetsample, a size, a shape, or the intra prediction mode of the currentblock.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, the bi-directional intra predictionmay be applied only to a predetermined region in the current block.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, determining whether thebi-directional intra prediction is applied to the current block maycomprise determining whether the intra prediction mode of the currentblock is a directional intra prediction mode, and decoding informationindicating whether the directional intra prediction mode is used as thebi-directional intra prediction mode.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, whether the bi-directional intraprediction is applied to the current block may be determined based onwhether bi-directional intra prediction is applied to a neighboringblock neighboring the current block.

In a method and an apparatus for encoding/decoding a video signalaccording to the present invention, when the intra prediction mode ofthe current block is a directional intra prediction mode within apredetermined range, it may be determined that the bi-directional intraprediction is applied to the current block.

The features briefly summarized above for the present invention are onlyillustrative aspects of the detailed description of the invention thatfollows, but do not limit the scope of the invention.

Advantageous Effects

According to the present invention, an efficient intra prediction may beperformed for an encoding/decoding target block.

According to the present invention, there is an advantage of increasingthe efficiency of intra prediction by performing intra prediction usinga plurality of reference samples that is not adjacent to each other.

According to the present invention, there is an advantage that theefficiency of intra prediction can be improved by using the right andbottom reference samples.

The effects obtainable by the present invention are not limited to theabove-mentioned effects, and other effects not mentioned can be clearlyunderstood by those skilled in the art from the description below.

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram illustrating a device for encoding a videoaccording to an embodiment of the present invention.

FIG. 2 is a block diagram illustrating a device for decoding a videoaccording to an embodiment of the present invention.

FIG. 3 is a diagram illustrating an example of hierarchicallypartitioning a coding block based on a tree structure according to anembodiment of the present invention.

FIG. 4 is a diagram illustrating a partition type in which binarytree-based partitioning is allowed according to an embodiment of thepresent invention.

FIGS. 5A and 5B are diagrams illustrating an example in which only abinary tree-based partition of a pre-determined type is allowedaccording to an embodiment of the present invention.

FIG. 6 is a diagram for explaining an example in which informationrelated to the allowable number of binary tree partitioning isencoded/decoded, according to an embodiment to which the presentinvention is applied.

FIG. 7 is a diagram illustrating a partition mode applicable to a codingblock according to an embodiment of the present invention.

FIG. 8 is a diagram illustrating types of pre-defined intra predictionmodes for a device for encoding/decoding a video according to anembodiment of the present invention.

FIG. 9 is a diagram illustrating a kind of extended intra predictionmodes according to an embodiment of the present invention.

FIG. 10 is a flowchart briefly illustrating an intra prediction methodaccording to an embodiment of the present invention.

FIG. 11 is a diagram illustrating a method of correcting a predictionsample of a current block based on differential information ofneighboring samples according to an embodiment of the present invention.

FIGS. 12 and 13 are diagrams illustrating a one-dimensional referencesample group in which reference samples are rearranged in a line.

FIGS. 14A and 14B are diagrams illustrating an example of deriving aright reference sample or a bottom reference sample using a plurality ofreference samples.

FIGS. 15 and 16 are diagrams for explaining determining a rightreference sample and a bottom reference sample for a non-square blockaccording to an embodiment of the present invention.

FIG. 17 is a diagram for explaining an example of deriving a secondreference sample using a first reference sample.

FIGS. 18A and 18B are diagrams illustrating reference samples thatconstitute a one-dimensional reference sample group.

FIG. 19 is an example of a region to which bi-directional intraprediction is applied.

FIG. 20 is an example of identifying and indicating a directionalprediction mode in which bi-directional intra prediction is allowed.

FIG. 21 is a flowchart illustrating an intra prediction method of acurrent block based on a bi-directional intra prediction mode accordingto the present invention.

MODE FOR INVENTION

A variety of modifications may be made to the present invention andthere are various embodiments of the present invention, examples ofwhich will now be provided with reference to drawings and described indetail. However, the present invention is not limited thereto, and theexemplary embodiments can be construed as including all modifications,equivalents, or substitutes in a technical concept and a technical scopeof the present invention. The similar reference numerals refer to thesimilar element in described the drawings.

Terms used in the specification, ‘first’, ‘second’, etc. can be used todescribe various components, but the components are not to be construedas being limited to the terms. The terms are only used to differentiateone component from other components. For example, the ‘first’ componentmay be named the ‘second’ component without departing from the scope ofthe present invention, and the ‘second’ component may also be similarlynamed the ‘first’ component. The term ‘and/or’ includes a combination ofa plurality of items or any one of a plurality of terms.

It will be understood that when an element is simply referred to asbeing ‘connected to’ or ‘coupled to’ another element without being‘directly connected to’ or ‘directly coupled to’ another element in thepresent description, it may be ‘directly connected to’ or ‘directlycoupled to’ another element or be connected to or coupled to anotherelement, having the other element intervening therebetween. In contrast,it should be understood that when an element is referred to as being“directly coupled” or “directly connected” to another element, there areno intervening elements present.

The terms used in the present specification are merely used to describeparticular embodiments, and are not intended to limit the presentinvention. An expression used in the singular encompasses the expressionof the plural, unless it has a clearly different meaning in the context.In the present specification, it is to be understood that terms such as“including”, “having”, etc. are intended to indicate the existence ofthe features, numbers, steps, actions, elements, parts, or combinationsthereof disclosed in the specification, and are not intended to precludethe possibility that one or more other features, numbers, steps,actions, elements, parts, or combinations thereof may exist or may beadded.

Hereinafter, preferred embodiments of the present invention will bedescribed in detail with reference to the accompanying drawings.Hereinafter, the same constituent elements in the drawings are denotedby the same reference numerals, and a repeated description of the sameelements will be omitted.

FIG. 1 is a block diagram illustrating a device for encoding a videoaccording to an embodiment of the present invention.

Referring to FIG. 1, the device 100 for encoding a video may include: apicture partitioning module 110, prediction modules 120 and 125, atransform module 130, a quantization module 135, a rearrangement module160, an entropy encoding module 165, an inverse quantization module 140,an inverse transform module 145, a filter module 150, and a memory 155.

The constitutional parts shown in FIG. 1 are independently shown so asto represent characteristic functions different from each other in thedevice for encoding a video, and does not mean that each constitutionalpart is constituted in a constitutional unit of separated hardware orsoftware. In other words, each constitutional part includes each ofenumerated constitutional parts for convenience. Thus, at least twoconstitutional parts of each constitutional part may be combined to formone constitutional part or one constitutional part may be partitionedinto a plurality of constitutional parts to perform each function. Theembodiment where each constitutional part is combined and the embodimentwhere one constitutional part is partitioned are also included in thescope of the present invention, if not departing from the essence of thepresent invention.

Also, some of constituents may not be indispensable constituentsperforming essential functions of the present invention but be selectiveconstituents improving only performance thereof. The present inventionmay be implemented by including only the indispensable constitutionalparts for implementing the essence of the present invention except theconstituents used in improving performance. The structure including onlythe indispensable constituents except the selective constituents used inimproving only performance is also included in the scope of the presentinvention.

The picture partitioning module 110 may partition an input picture intoone or more processing units. Here, the processing unit may be aprediction unit (PU), a transform unit (TU), or a coding unit (CU). Thepicture partitioning module 110 may partition one picture intocombinations of a plurality of coding units, prediction units, andtransform units, and may encode a picture by selecting one combinationof coding units, prediction units, and transform units with apredetermined criterion (e.g., cost function).

For example, one picture may be partitioned into a plurality of codingunits. A recursive tree structure, such as a quad tree structure, may beused to partition a picture into coding units. A coding unit which ispartitioned into other coding units with one picture or a largest codingunit as a root may be partitioned with child nodes corresponding to thenumber of partitioned coding units. A coding unit which is no longerpartitioned by a predetermined limitation serves as a leaf node. Thatis, when it is assumed that only square partitioning is possible for onecoding unit, one coding unit may be partitioned into four other codingunits at most.

Hereinafter, in the embodiment of the present invention, the coding unitmay mean a unit performing encoding, or a unit performing decoding.

A prediction unit may be one of partitions partitioned into a square ora rectangular shape having the same size in a single coding unit, or aprediction unit may be one of partitions partitioned so that oneprediction unit of prediction units partitioned in a single coding unithave a different shape and/or size from other prediction unit.

When a prediction unit performing intra prediction based on a codingunit is generated and the coding unit is not the smallest coding unit,intra prediction may be performed without partitioning the coding unitinto a plurality of prediction units N×N.

The prediction modules 120 and 125 may include an inter predictionmodule 120 performing inter prediction and an intra prediction module125 performing intra prediction. Whether to perform inter prediction orintra prediction for the prediction unit may be determined, and detailedinformation (e.g., an intra prediction mode, a motion vector, areference picture, etc.) according to each prediction method may bedetermined. Here, the processing unit performing prediction may bedifferent from the processing unit for which the prediction method anddetailed content is determined. For example, the prediction method, theprediction mode, etc. may be determined on the basis of the predictionunit, and prediction may be performed on the basis of the transformunit. A residual value (residual block) between the generated predictionblock and an original block may be input to the transform module 130.Also, prediction mode information, motion vector information, etc. usedfor prediction may be encoded with the residual value in the entropyencoding module 165 and may be transmitted to a device for decoding avideo. When a particular encoding mode is used, it is possible totransmit to a device for decoding video by encoding the original blockas it is without generating the prediction block through the predictionmodules 120 and 125.

The inter prediction module 120 may predict the prediction unit based oninformation of at least one of a previous picture or a subsequentpicture of the current picture, or may predict the prediction unit basedon information of some encoded regions in the current picture, in somecases. The inter prediction module 120 may include a reference pictureinterpolation module, a motion prediction module, and a motioncompensation module.

The reference picture interpolation module may receive reference pictureinformation from the memory 155 and may generate pixel information of aninteger pixel or less then the integer pixel from the reference picture.In the case of luma pixels, an 8-tap DCT-based interpolation filterhaving different filter coefficients may be used to generate pixelinformation of an integer pixel or less than an integer pixel on thebasis of a ¼ pixel. In the case of chroma signals, a 4-tap DCT-basedinterpolation filter having different filter coefficient may be used togenerate pixel information of an integer pixel or less than an integerpixel on the basis of a ⅛ pixel.

The motion prediction module may perform motion prediction based on thereference picture interpolated by the reference picture interpolationmodule. As methods for calculating a motion vector, various methods,such as a full search-based block matching algorithm (FBMA), a threestep search (TSS), a new three-step search algorithm (NTS), etc., may beused. The motion vector may have a motion vector value on the basis of a½ pixel or a ¼ pixel based on an interpolated pixel. The motionprediction module may predict a current prediction unit by changing themotion prediction method. As motion prediction methods, various methods,such as a skip method, a merge method, an AMVP (Advanced Motion VectorPrediction) method, an intra block copy method, etc., may be used.

The intra prediction module 125 may generate a prediction unit based onreference pixel information neighboring to a current block which ispixel information in the current picture. When the neighboring block ofthe current prediction unit is a block subjected to inter prediction andthus a reference pixel is a pixel subjected to inter prediction, thereference pixel included in the block subjected to inter prediction maybe replaced with reference pixel information of a neighboring blocksubjected to intra prediction. That is, when a reference pixel is notavailable, at least one reference pixel of available reference pixelsmay be used instead of unavailable reference pixel information.

Prediction modes in intra prediction may include a directionalprediction mode using reference pixel information depending on aprediction direction and a non-directional prediction mode not usingdirectional information in performing prediction. A mode for predictingluma information may be different from a mode for predicting chromainformation, and in order to predict the chroma information, intraprediction mode information used to predict luma information orpredicted luma signal information may be utilized.

In performing intra prediction, when a size of the prediction unit isthe same as a size of the transform unit, intra prediction may beperformed on the prediction unit based on pixels positioned at the left,the top left, and the top of the prediction unit. However, in performingintra prediction, when the size of the prediction unit is different fromthe size of the transform unit, intra prediction may be performed usinga reference pixel based on the transform unit. Also, intra predictionusing N×N partitioning may be used for only the smallest coding unit.

In the intra prediction method, a prediction block may be generatedafter applying an AIS (Adaptive Intra Smoothing) filter to a referencepixel depending on the prediction modes. A type of the AIS filterapplied to the reference pixel may vary. In order to perform the intraprediction method, an intra prediction mode of the current predictionunit may be predicted from the intra prediction mode of the predictionunit neighboring to the current prediction unit. In prediction of theprediction mode of the current prediction unit by using mode informationpredicted from the neighboring prediction unit, when the intraprediction mode of the current prediction unit is the same as the intraprediction mode of the neighboring prediction unit, informationindicating that the prediction modes of the current prediction unit andthe neighboring prediction unit are equal to each other may betransmitted using predetermined flag information. When the predictionmode of the current prediction unit is different from the predictionmode of the neighboring prediction unit, entropy encoding may beperformed to encode prediction mode information of the current block.

Also, a residual block including information on a residual value whichis a different between the prediction unit subjected to prediction andthe original block of the prediction unit may be generated based onprediction units generated by the prediction modules 120 and 125. Thegenerated residual block may be input to the transform module 130.

The transform module 130 may transform the residual block including theinformation on the residual value between the original block and theprediction unit generated by the prediction modules 120 and 125 by usinga transform method, such as discrete cosine transform (DCT), discretesine transform (DST), and KLT. Whether to apply DCT, DST, or KLT inorder to transform the residual block may be determined based on intraprediction mode information of the prediction unit used to generate theresidual block.

The quantization module 135 may quantize values transformed to afrequency domain by the transform module 130. Quantization coefficientsmay vary depending on the block or importance of a picture. The valuescalculated by the quantization module 135 may be provided to the inversequantization module 140 and the rearrangement module 160.

The rearrangement module 160 may rearrange coefficients of quantizedresidual values.

The rearrangement module 160 may change a coefficient in the form of atwo-dimensional block into a coefficient in the form of aone-dimensional vector through a coefficient scanning method. Forexample, the rearrangement module 160 may scan from a DC coefficient toa coefficient in a high frequency domain using a zigzag scanning methodso as to change the coefficients to be in the form of one-dimensionalvectors. Depending on a size of the transform unit and the intraprediction mode, vertical direction scanning where coefficients in theform of two-dimensional blocks are scanned in the column direction orhorizontal direction scanning where coefficients in the form oftwo-dimensional blocks are scanned in the row direction may be usedinstead of zigzag scanning. That is, which scanning method among zigzagscanning, vertical direction scanning, and horizontal direction scanningis used may be determined depending on the size of the transform unitand the intra prediction mode.

The entropy encoding module 165 may perform entropy encoding based onthe values calculated by the rearrangement module 160. Entropy encodingmay use various encoding methods, for example, exponential Golombcoding, context-adaptive variable length coding (CAVLC), andcontext-adaptive binary arithmetic coding (CABAC).

The entropy encoding module 165 may encode a variety of information,such as residual value coefficient information and block typeinformation of the coding unit, prediction mode information, partitionunit information, prediction unit information, transform unitinformation, motion vector information, reference frame information,block interpolation information, filtering information, etc. from therearrangement module 160 and the prediction modules 120 and 125.

The entropy encoding module 165 may entropy encode the coefficients ofthe coding unit input from the rearrangement module 160.

The inverse quantization module 140 may inversely quantize the valuesquantized by the quantization module 135 and the inverse transformmodule 145 may inversely transform the values transformed by thetransform module 130. The residual value generated by the inversequantization module 140 and the inverse transform module 145 may becombined with the prediction unit predicted by a motion estimationmodule, a motion compensation module, and the intra prediction module ofthe prediction modules 120 and 125 such that a reconstructed block canbe generated.

The filter module 150 may include at least one of a deblocking filter,an offset correction unit, or an adaptive loop filter (ALF).

The deblocking filter may remove block distortion that occurs due toboundaries between the blocks in the reconstructed picture. In order todetermine whether to perform deblocking, the pixels included in severalrows or columns in the block may be a basis of determining whether toapply the deblocking filter to the current block. When the deblockingfilter is applied to the block, a strong filter or a weak filter may beapplied depending on required deblocking filtering strength. Also, inapplying the deblocking filter, horizontal direction filtering andvertical direction filtering may be processed in parallel.

The offset correction module may correct offset with the originalpicture on the basis of a pixel in the picture subjected to deblocking.In order to perform the offset correction on a particular picture, it ispossible to use a method of applying offset in consideration of edgeinformation of each pixel or a method of partitioning pixels of apicture into the predetermined number of regions, determining a regionto be subjected to perform offset, and applying the offset to thedetermined region.

Adaptive loop filtering (ALF) may be performed based on the valueobtained by comparing the filtered reconstructed picture and theoriginal picture. The pixels included in the picture may be partitionedinto predetermined groups, a filter to be applied to each of the groupsmay be determined, and filtering may be individually performed for eachgroup. Information on whether to apply ALF and a luma signal may betransmitted by coding units (CU). The shape and filter coefficient of afilter for ALF may vary depending on each block. Also, the filter forALF in the same shape (fixed shape) may be applied regardless ofcharacteristics of the application target block.

The memory 155 may store the reconstructed block or picture calculatedthrough the filter module 150. The stored reconstructed block or picturemay be provided to the prediction modules 120 and 125 in performinginter prediction.

FIG. 2 is a block diagram illustrating a device for decoding a videoaccording to an embodiment of the present invention.

Referring to FIG. 2, the device 200 for decoding a video may include: anentropy decoding module 210, a rearrangement module 215, an inversequantization module 220, an inverse transform module 225, predictionmodules 230 and 235, a filter module 240, and a memory 245.

When a video bitstream is input from the device for encoding a video,the input bitstream may be decoded according to an inverse process ofthe device for encoding a video.

The entropy decoding module 210 may perform entropy decoding accordingto an inverse process of entropy encoding by the entropy encoding moduleof the device for encoding a video. For example, corresponding to themethods performed by the device for encoding a video, various methods,such as exponential Golomb coding, context-adaptive variable lengthcoding (CAVLC), and context-adaptive binary arithmetic coding (CABAC)may be applied.

The entropy decoding module 210 may decode information on intraprediction and inter prediction performed by the device for encoding avideo.

The rearrangement module 215 may perform rearrangement on the bitstreamentropy decoded by the entropy decoding module 210 based on therearrangement method used in the device for encoding a video. Therearrangement module may reconstruct and rearrange the coefficients inthe form of one-dimensional vectors to the coefficient in the form oftwo-dimensional blocks. The rearrangement module 215 may receiveinformation related to coefficient scanning performed in the device forencoding a video and may perform rearrangement via a method of inverselyscanning the coefficients based on the scanning order performed in thedevice for encoding a video.

The inverse quantization module 220 may perform inverse quantizationbased on a quantization parameter received from the device for encodinga video and the rearranged coefficients of the block.

The inverse transform module 225 may perform the inverse transform,i.e., inverse DCT, inverse DST, and inverse KLT, which is the inverseprocess of transform, i.e., DCT, DST, and KLT, performed by thetransform module on the quantization result by the device for encoding avideo. Inverse transform may be performed based on a transfer unitdetermined by the device for encoding a video. The inverse transformmodule 225 of the device for decoding a video may selectively performtransform schemes (e.g., DCT, DST, and KLT) depending on a plurality ofpieces of information, such as the prediction method, a size of thecurrent block, the prediction direction, etc.

The prediction modules 230 and 235 may generate a prediction block basedon information on prediction block generation received from the entropydecoding module 210 and previously decoded block or picture informationreceived from the memory 245.

As described above, like the operation of the device for encoding avideo, in performing intra prediction, when a size of the predictionunit is the same as a size of the transform unit, intra prediction maybe performed on the prediction unit based on the pixels positioned atthe left, the top left, and the top of the prediction unit. Inperforming intra prediction, when the size of the prediction unit isdifferent from the size of the transform unit, intra prediction may beperformed using a reference pixel based on the transform unit. Also,intra prediction using N×N partitioning may be used for only thesmallest coding unit.

The prediction modules 230 and 235 may include a prediction unitdetermination module, an inter prediction module, and an intraprediction module. The prediction unit determination module may receivea variety of information, such as prediction unit information,prediction mode information of an intra prediction method, informationon motion prediction of an inter prediction method, etc. from theentropy decoding module 210, may partition a current coding unit intoprediction units, and may determine whether inter prediction or intraprediction is performed on the prediction unit. By using informationrequired in inter prediction of the current prediction unit receivedfrom the device for encoding a video, the inter prediction module 230may perform inter prediction on the current prediction unit based oninformation of at least one of a previous picture or a subsequentpicture of the current picture including the current prediction unit.Alternatively, inter prediction may be performed based on information ofsome pre-reconstructed regions in the current picture including thecurrent prediction unit.

In order to perform inter prediction, it may be determined for thecoding unit which of a skip mode, a merge mode, an AMVP mode, and aninter block copy mode is used as the motion prediction method of theprediction unit included in the coding unit.

The intra prediction module 235 may generate a prediction block based onpixel information in the current picture. When the prediction unit is aprediction unit subjected to intra prediction, intra prediction may beperformed based on intra prediction mode information of the predictionunit received from the device for encoding a video. The intra predictionmodule 235 may include an adaptive intra smoothing (AIS) filter, areference pixel interpolation module, and a DC filter. The AIS filterperforms filtering on the reference pixel of the current block, andwhether to apply the filter may be determined depending on theprediction mode of the current prediction unit. AIS filtering may beperformed on the reference pixel of the current block by using theprediction mode of the prediction unit and AIS filter informationreceived from the device for encoding a video. When the prediction modeof the current block is a mode where AIS filtering is not performed, theAIS filter may not be applied.

When the prediction mode of the prediction unit is a prediction mode inwhich intra prediction is performed based on the pixel value obtained byinterpolating the reference pixel, the reference pixel interpolationmodule may interpolate the reference pixel to generate the referencepixel of an integer pixel or less than an integer pixel. When theprediction mode of the current prediction unit is a prediction mode inwhich a prediction block is generated without interpolation thereference pixel, the reference pixel may not be interpolated. The DCfilter may generate a prediction block through filtering when theprediction mode of the current block is a DC mode.

The reconstructed block or picture may be provided to the filter module240. The filter module 240 may include the deblocking filter, the offsetcorrection module, and the ALF.

Information on whether or not the deblocking filter is applied to thecorresponding block or picture and information on which of a strongfilter and a weak filter is applied when the deblocking filter isapplied may be received from the device for encoding a video. Thedeblocking filter of the device for decoding a video may receiveinformation on the deblocking filter from the device for encoding avideo, and may perform deblocking filtering on the corresponding block.

The offset correction module may perform offset correction on thereconstructed picture based on a type of offset correction and offsetvalue information applied to a picture in performing encoding.

The ALF may be applied to the coding unit based on information onwhether to apply the ALF, ALF coefficient information, etc. receivedfrom the device for encoding a video. The ALF information may beprovided as being included in a particular parameter set.

The memory 245 may store the reconstructed picture or block for use as areference picture or block, and may provide the reconstructed picture toan output module.

As described above, in the embodiment of the present invention, forconvenience of explanation, the coding unit is used as a termrepresenting a unit for encoding, but the coding unit may serve as aunit performing decoding as well as encoding.

In addition, a current block may represent a target block to beencoded/decoded. And, the current block may represent a coding treeblock (or a coding tree unit), a coding block (or a coding unit), atransform block (or a transform unit), a prediction block (or aprediction unit), or the like depending on an encoding/decoding step.

A picture may be encoded/decoded by partitioned into base blocks havinga square shape or a non-square shape. At this time, the base block maybe referred to as a coding tree unit. The coding tree unit may bedefined as a coding unit of the largest size allowed within a sequenceor a slice. Information regarding whether the coding tree unit has asquare shape or has a non-square shape or information regarding a sizeof the coding tree unit may be signaled through a sequence parameterset, a picture parameter set, or a slice header. The coding tree unitmay be partitioned into smaller size partitions. At this time, if it isassumed that a depth of a partition generated by dividing the codingtree unit is 1, a depth of a partition generated by dividing thepartition having depth 1 may be defined as 2. That is, a partitiongenerated by dividing a partition having a depth k in the coding treeunit may be defined as having a depth k+1.

A partition of arbitrary size generated by dividing a coding tree unitmay be defined as a coding unit. The coding unit may be recursivelypartitioned or partitioned into base units for performing prediction,quantization, transform, or in-loop filtering, or the like. For example,a partition of arbitrary size generated by dividing the coding unit maybe defined as a coding unit, or may be defined as a transform unit or aprediction unit, which is a base unit for performing prediction,quantization, transform, in-loop filtering, or the like.

Partitioning of a coding tree unit or a coding unit may be performedbased on at least one of the vertical line or the horizontal line. Inaddition, the number of vertical lines or horizontal lines partitioningthe coding tree unit or the coding unit may be at least one or more. Forexample, the coding tree unit or the coding unit may be partitioned intotwo partitions using one vertical line or one horizontal line, or thecoding tree unit or the coding unit may be partitioned into threepartitions using two vertical lines or two horizontal lines.Alternatively, the coding tree unit or the coding unit may bepartitioned into four partitions having a length and the width of byusing one vertical line and one horizontal line.

When a coding tree unit or a coding unit is partitioned into a pluralityof partitions using at least one vertical line or at least onehorizontal line, the partitions may have a uniform size or a differentsize. Alternatively, any one partition may have a different size fromthe remaining partitions.

In the embodiments described below, it is assumed that a coding treeunit or a coding unit is partitioned into a quad tree structure, atriple tree structure, or a binary tree structure. However, it is alsopossible to partition a coding tree unit or a coding unit using a largernumber of vertical lines or a larger number of horizontal lines.

FIG. 3 is a diagram illustrating an example of hierarchicallypartitioning a coding block based on a tree structure as an embodimentto which the present invention is applied.

An input video signal is decoded in predetermined block units. Such adefault unit for decoding the input video signal is a coding block. Thecoding block may be a unit performing intra/inter prediction, transform,and quantization. In addition, a prediction mode (e.g., intra predictionmode or inter prediction mode) is determined on the basis of a codingblock, and the prediction blocks included in the coding block may sharethe determined prediction mode. The coding block may be a square ornon-square block having an arbitrary size in a range of 8×8 to 64×64, ormay be a square or non-square block having a size of 128×128, 256×256,or more.

Specifically, the coding block may be hierarchically partitioned basedon at least one of a quad tree, a triple tree, or a binary tree. Here,quad tree-based partitioning may mean that a 2N×2N coding block ispartitioned into four N×N coding blocks, triple tree-based partitioningmay mean that one coding block is partitioned into three coding blocks,and binary-based partitioning may mean that one coding block ispartitioned into two coding blocks. Even if the triple-basedpartitioning or the binary tree-based partitioning is performed, asquare-shaped coding block may exist in the lower depth. Also, after thetriple-based partitioning or the binary-based partitioning is performed,generating a square-shaped coding block may be limited in a lower depth.

Binary tree-based partitioning may be symmetrically or asymmetricallyperformed. The coding block partitioned based on the binary tree may bea square block or a non-square block, such as a rectangular shape. Forexample, a partition type in which the binary tree-based partitioning isallowed may comprise at least one of a symmetric type of 2N×N(horizontal directional non-square coding unit) or N×2N (verticaldirection non-square coding unit), asymmetric type of nL×2N, nR×2N,2N×nU, or 2N×nD.

Binary tree-based partitioning may be limitedly allowed to one of asymmetric or an asymmetric type partition. In this case, constructingthe coding tree unit with square blocks may correspond to quad tree CUpartitioning, and constructing the coding tree unit with symmetricnon-square blocks may correspond to binary tree partitioning.Constructing the coding tree unit with square blocks and symmetricnon-square blocks may correspond to quad and binary tree CUpartitioning.

Binary tree-based partitioning may be performed on a coding block wherequad tree-based partitioning is no longer performed. At least one ofquad tree-based partitioning, triple tree-based partitioning, or binarytree-based partitioning may no longer be performed on the coding blockpartitioned based on the binary tree.

Alternatively, the triple tree-based partitioning or the binarytree-based partitioning may be allowed for the coding block partitionedbased on the binary tree, but only one of the horizontal or verticalpartitioning may be limitedly allowed.

For example, an additional partition or an additional partitiondirection may be limited for a coding block partitioned based on thebinary tree according to a location, an index, a shape, or an additionalpartition type of a neighboring partition of the coding blockpartitioned based on the binary tree, or the like. For example, when anindex of the coding block that precedes the coding order among the twocoding blocks generated by the binary tree based-partitioning is 0(hereinafter referred to as coding block index 0) and an index of thecoding block that follows the coding order among the two coding blocksgenerated by the binary tree-based partitioning is 1 (hereinafterreferred to as coding block index 1), in the case where the binarytree-based partitioning is applied to all coding blocks having a codingblock index of 0 or a coding block index of 1, the binary tree-basedpartitioning direction of the coding block having the coding block indexof 1 may be determined according to a binary tree-based partitioningdirection of the coding block having the coding block index of 0.Specifically, when the binary tree-based partitioning direction of thecoding block having the coding block index of 0 is to partition thecoding block having the coding block index of 0 into square partitions,binary tree-based partitioning of the coding block having the codingblock index of 1 may be limited to have a different direction frombinary tree-based partitioning of the coding block having a coding blockindex of 1. Thus, the coding blocks having the coding block index of 0and the coding block index of 1 may be restricted from being partitionedinto square partitions. In this case, encoding/decoding of informationindicating the binary tree partitioning direction of the coding blockhaving the coding block index of 1 may be omitted. This is becausepartitioning all of the coding blocks having the coding block index of 0and the coding block index of 1 into square partitions has the sameeffect as partitioning the upper depth block on the basis of a quadtree, so that allowing partitioning of all into square partitions isundesirable in terms of coding efficiency.

Triple tree-based partitioning means partitioning a coding block intothree partitions in the horizontal or vertical direction. All threepartitions generated due to triple tree-based partitioning may havedifferent sizes. Alternatively, two of the partitions generated due totriple tree-based partitioning may have the same size, and the other onemay have a different size. For example, the width ratio or height ratioof partitions generated as the coding block is partitioned may be set to1:n:1, 1:1:n, n:1:1 or m:n:1 depending on the partitioning direction.Here, m and n may be 1 or a real number greater than 1, for example, aninteger such as 2.

Triple tree-based partitioning may be performed on a coding block inwhich quad tree-based partitioning is no longer performed. For thecoding block partitioned based on the triple tree, at least one of quadtree-based partitioning, triple tree-based partitioning, or binarytree-based partitioning may be set to no longer be performed.

Alternatively, triple tree-based partitioning or binary tree-basedpartitioning may be allowed for the coding block partitioned based onthe triple tree, but only one of horizontal or vertical partitioning maybe limitedly allowed.

For example, an additional partition or an additional partitiondirection may be limited for a coding block partitioned based on thetriple tree according to a location, an index, a shape, or an additionalpartition type of a neighboring partition of the coding blockpartitioned based on the triple tree, or the like. For example, one ofhorizontal division or vertical division may be limited to a partitionhaving the largest size among coding blocks generated due to tripletree-based partitioning. Specifically, the largest partition amongcoding blocks generated due to triple tree-based partitioning may notallow binary tree partitioning in the same direction or triple treepartitioning direction in the same direction as the triple treepartitioning direction of the upper depth partition. In this case,encoding/decoding of information indicating the binary tree partitioningdirection or the triple tree partitioning direction may be omitted forthe largest partition among the coding blocks partitioned based on thetriple tree.

Partitioning based on a binary tree or a triple tree may not be allowedaccording to a size or a shape of a current block. Here, the size of thecurrent block may be expressed based on at least one of a width, aheight of the current block, a minimum/maximum of the width/height, asum of the width and the height, a product of the width and height, orthe number of samples included in the current block. For example, whenat least one of the width or the height of the current block is greaterthan a pre-defined value, partitioning based on a binary tree or atriple tree may not be allowed. Herein, the pre-defined value may be aninteger such as 16, 32, 64, or 128. As another example, when awidth-to-height ratio of the current block is greater than a pre-definedvalue or smaller than a pre-defined value, partitioning based on abinary tree or a triple tree may not be allowed. When the predefinedvalue is 1, partitioning based on a binary tree or triple tree may beallowed only when the current block is a square block having the samewidth and height.

The partitioning in the lower depth may be determined depending on thepartitioning type of the upper depth. For example, when binarytree-based partitioning is allowed in two or more depths, only a binarytree-based partitioning of the same type as a binary tree partitioningof an upper depth may be allowed in a lower depth. For example, when thebinary tree-based partitioning is performed in the 2N×N type in theupper depth, the binary tree-based partitioning in the 2N×N type may beperformed in the lower depth. Alternatively, when binary tree-basedpartitioning is performed in an N×2N type in an upper depth, N×2N-typebinary tree-based partitioning may be allowed in a lower depth.

Conversely, it is also possible to allow only binary tree-basedpartitioning having a different type from the binary tree partitioningof the upper depth in the lower depth.

For a sequence, a slice, a coding tree unit, or a coding unit, it may belimited to use only a special type of binary tree-based partitioning ora special type of triple tree-based partitioning. For example, it may belimited to allow only 2N×N or N×2N type binary tree-based partitioningfor a coding tree unit. The allowed partitioning type may be predefinedin the encoder or the decoder, and information about the allowedpartitioning type or the not allowed partitioning type may be encodedand signaled through a bitstream.

FIGS. 5A and 5B are diagrams illustrating an example in which only aspecific type of binary tree-based partitioning is allowed. FIG. 5Ashows an example in which only N×2N type of binary tree-basedpartitioning is allowed, and FIG. 5B shows an example in which only 2N×Ntype of binary tree-based partitioning is allowed. In order to implementadaptive partitioning based on the quad tree or binary tree, informationindicating quad tree-based partitioning, information on a size/depth ofthe coding block that quad tree-based partitioning is allowed,information indicating binary tree-based partitioning, information onthe size/depth of the coding block that binary tree-based partitioningis allowed, information on the size/depth of the coding block thatbinary tree-based partitioning is not allowed, information on whetherbinary tree-based partitioning is performed in the vertical direction orthe horizontal direction, etc. may be used.

In addition, information on the number of times a binary/triple treepartitioning is allowed, a depth in which the binary/triple treepartitioning is allowed, or the number of the depths in which thebinary/triple tree partitioning is allowed may be obtained for a codingtree unit or a specific coding unit. The information may be encoded onthe basis of a coding tree unit or a coding unit, and may be transmittedto a decoder through a bitstream.

For example, a syntax ‘max_binary_depth_idx_minus1’ indicating a maximumdepth in which binary tree partitioning is allowed may beencoded/decoded through a bitstream. In this case,max_binary_depth_idx_minus1+1 may indicate the maximum depth in whichthe binary tree partitioning is allowed.

Referring to an example shown in FIG. 6, in FIG. 6, the binary treepartitioning has been performed for a coding unit having a depth of 2and a coding unit having a depth of 3. Accordingly, at least one ofinformation indicating the number of times the binary tree partitioningin the coding tree unit has been performed (i.e., 2 times), informationindicating the maximum depth in which the binary tree partitioning hasbeen allowed in the coding tree unit (i.e., depth 3), or the number ofdepths in which the binary tree partitioning has been performed in thecoding tree unit (i.e., 2 (depth 2 and depth 3)) may be encoded/decodedthrough a bitstream.

As another example, at least one of information on the number of timesthe binary/triple tree partitioning is allowed, the depth in which thebinary/triple tree partitioning is allowed, or the number of the depthsin which the binary/triple tree partitioning is allowed may be obtainedfor each sequence or each slice. For example, the information may beencoded on the basis of a sequence, a picture, or a slice unit andtransmitted through a bitstream. In contrast, a depth in which thebinary/triple tree partitioning is allowed, or the number of the depthsin which the binary/triple tree partitioning is allowed may be definedfor each a sequence, a picture, or a slice unit. Accordingly, at leastone of the number of the binary/triple tree partitioning in the firstslice and the second slice, the maximum depth in which the binary/tripletree partitioning is allowed in the first slice and the second slice, orthe number of depths in which the binary/triple tree partitioning isperformed in the first slice and the second slice may be difference froma second slice. For example, in the first slice, binary treepartitioning may be allowed for only one depth, while in the secondslice, binary tree partitioning may be allowed for two depths.

As another example, the number of times the binary/triple treepartitioning is allowed, the depth in which the binary/triple treepartitioning is allowed, or the number of depths in which thebinary/triple tree partitioning is allowed may be set differentlyaccording to a time level identifier (TemporalID) of a slice or apicture. Here, the temporal level identifier (TemporalID) is used toidentify each of a plurality of layers of video having a scalability ofat least one of view, spatial, temporal or quality.

As shown in FIG. 3, the first coding block 300 with the partition depth(split depth) of k may be partitioned into a plurality of second codingblocks based on the quad tree. For example, the second coding blocks 310to 340 may be square blocks having the half width and the half height ofthe first coding block, and the partition depth of the second codingblock may be increased to k+1.

The second coding block 310 with the partition depth of k+1 may bepartitioned into a plurality of third coding blocks with the partitiondepth of k+2. Partitioning of the second coding block 310 may beperformed by selectively using one of the quad tree and the binary treedepending on a partitioning method. Here, the partitioning method may bedetermined based on at least one of the information indicating quadtree-based partitioning or the information indicating binary tree-basedpartitioning.

When the second coding block 310 is partitioned based on the quad tree,the second coding block 310 may be partitioned into four third codingblocks 310 a having the half width and the half height of the secondcoding block, and the partition depth of the third coding block 310 amay be increased to k+2. In contrast, when the second coding block 310is partitioned based on the binary tree, the second coding block 310 maybe partitioned into two third coding blocks. Here, each of two thirdcoding blocks may be a non-square block having one of the half width andthe half height of the second coding block, and the partition depth maybe increased to k+2. The second coding block may be determined as anon-square block of the horizontal direction or the vertical directiondepending on a partitioning direction, and the partitioning directionmay be determined based on the information on whether binary tree-basedpartitioning is performed in the vertical direction or the horizontaldirection.

In the meantime, the second coding block 310 may be determined as a leafcoding block that is no longer partitioned based on the quad tree or thebinary tree. In this case, the leaf coding block may be used as aprediction block or a transform block.

Like partitioning of the second coding block 310, the third coding block310 a may be determined as a leaf coding block, or may be furtherpartitioned based on the quad tree or the binary tree.

In the meantime, the third coding block 310 b partitioned based on thebinary tree may be further partitioned into coding blocks 310 b-2 of thevertical direction or coding blocks 310 b-3 of the horizontal directionbased on the binary tree, and the partition depth of the relevant codingblocks may be increased to k+3. Alternatively, the third coding block310 b may be determined as a leaf coding block 310 b-1 that is no longerpartitioned based on the binary tree. In this case, the coding block 310b-1 may be used as a prediction block or a transform block. However, theabove partitioning process may be limitedly performed based on at leastone of the information on a size/depth of the coding block that quadtree-based partitioning is allowed, the information on the size/depth ofthe coding block that binary tree-based partitioning is allowed, or theinformation on the size/depth of the coding block that binary tree-basedpartitioning is not allowed.

A number of a candidate that represent a size of a coding block may belimited to a predetermined number, or the size of the coding block in apredetermined unit may have a fixed value. As an example, the size ofthe coding block in a sequence or in a picture may be limited to have256×256, 128×128, or 32×32. Information indicating the size of thecoding block in the sequence or in the picture may be signaled through asequence header or a picture header.

As a result of partitioning based on a quad tree, a binary tree and atriple tree, a coding unit may be represented as square or rectangularshape of an arbitrary size.

A coding block may be encoded/decoded using at least one of a skip mode,an intra prediction, an inter prediction, or a skip method.

As another example, intra prediction or inter prediction may beperformed on the same size as a coding block or a unit smaller than thecoding block generated by partitioning the coding block. Once a codingblock is determined, a prediction block may be determined throughpredictive partitioning of the coding block. The predictive partitioningof the coding block may be performed by a partition mode (Part mode)indicating a partition type of the coding block. A size or a shape ofthe prediction block may be determined according to the partition modeof the coding block. For example, a size of a prediction blockdetermined according to the partition mode may be equal to or smallerthan a size of a coding block.

FIG. 7 is a diagram illustrating a partition mode that may be applied toa coding block when the coding block is encoded by inter prediction.

When a coding block is encoded by inter prediction, one of 8partitioning modes may be applied to the coding block, as in an exampleshown in FIG. 4.

When a coding block is encoded by intra prediction, a partition modePART_2N×2N or a partition mode PART_N×N may be applied to the codingblock.

PART_N×N may be applied when a coding block has a minimum size. Here,the minimum size of the coding block may be pre-defined in an encoderand a decoder. Or, information regarding the minimum size of the codingblock may be signaled via a bitstream. For example, the minimum size ofthe coding block may be signaled through a slice header, so that theminimum size of the coding block may be defined per slice.

In general, a prediction block may have a size from 64×64 to 4×4.However, when a coding block is encoded by inter prediction, it may berestricted that the prediction block does not have a 4×4 size in orderto reduce memory bandwidth when performing motion compensation.

FIG. 8 is a diagram illustrating types of pre-defined intra predictionmodes for a device for encoding/decoding a video according to anembodiment of the present invention.

The device for encoding/decoding a video may perform intra predictionusing one of pre-defined intra prediction modes. The pre-defined intraprediction modes for intra prediction may include non-directionalprediction modes (e.g., a planar mode, a DC mode) and 33 directionalprediction modes.

Alternatively, in order to enhance accuracy of intra prediction, alarger number of directional prediction modes than the 33 directionalprediction modes may be used. That is, M extended directional predictionmodes may be defined by subdividing angles of the directional predictionmodes (M>33), and a directional prediction mode having a predeterminedangle may be derived using at least one of the 33 pre-defineddirectional prediction modes.

Specifically, a larger number of intra prediction modes than 35 intraprediction modes shown in FIG. 8 may be used. At this time, the use of alarger number of intra prediction modes than the 35 intra predictionmodes may be referred to as an extended intra prediction mode.

FIG. 9 illustrates an example of extended intra prediction modes, andthe extended intra prediction modes may include 2 non-directionalprediction modes and 65 extended directional prediction modes. The samenumbers of the extended intra prediction modes may be used for a lumacomponent and a chroma component, or a different number of intraprediction modes may be used for each component. For example, 67extended intra prediction modes may be used for the luma component, and35 intra prediction modes may be used for the chroma component.

Alternatively, depending on the chroma format, a different number ofintra prediction modes may be used in performing intra prediction. Forexample, in the case of the 4:2:0 format, 67 intra prediction modes maybe used for the luma component to perform intra prediction and 35 intraprediction modes may be used for the chroma component. In the case ofthe 4:4:4 format, 67 intra prediction modes may be used for both theluma component and the chroma component to perform intra prediction.

Alternatively, depending on a size and/or shape of the block, adifferent number of intra prediction modes may be used to perform intraprediction. That is, depending on a size and/or shape of the PU or CU,35 intra prediction modes or 67 intra prediction modes may be used toperform intra prediction. For example, when the CU or PU has the sizeless than 64×64 or is asymmetrically partitioned, 35 intra predictionmodes may be used to perform intra prediction. When the size of the CUor PU is equal to or greater than 64×64, 67 intra prediction modes maybe used to perform intra prediction. 65 directional intra predictionmodes may be allowed for Intra 2N×2N, and only 35 directional intraprediction modes may be allowed for Intra N×N.

A size of a block to which the extended intra prediction mode is appliedmay be set differently for each sequence, picture or slice. For example,it is set that the extended intra prediction mode is applied to a block(e.g., CU or PU) which has a size greater than 64×64 in the first slice.On the other hands, it is set that the extended intra prediction mode isapplied to a block which has a size greater than 32×32 in the secondslice. Information representing a size of a block to which the extendedintra prediction mode is applied may be signaled through on the basis ofa sequence, a picture, or a slice. For example, the informationindicating a size of the block to which the extended intra predictionmode is applied may be defined as ‘log2_extended_intra_mode_size_minus4’ obtained by taking a logarithm of theblock size and then subtracting the integer 4. For example, if a valueof log 2_extended_intra_mode_size_minus4 is 0, it may indicate that theextended intra prediction mode may be applied to a block having a sizeequal to or greater than 16×16. And if a value of log2_extended_intra_mode_size_minus4 is 1, it may indicate that theextended intra prediction mode may be applied to a block having a sizeequal to or greater than 32×32.

As described above, the number of intra prediction modes may bedetermined in consideration of at least one of a color component, achroma format, or a size or a shape of a block. In addition, the numberof intra prediction mode candidates (e.g., the number of MPMs) used fordetermining an intra prediction mode of a current block to beencoded/decoded may also be determined according to at least one of acolor component, a color format, or a size or a shape of a block. Inaddition, it is also possible to use a larger number of intra predictionmodes than shown in FIG. 8. For example, by further subdividing thedirectional prediction modes shown in FIG. 8, it is also possible to use129 directional prediction modes and 2 non-directional prediction modes.Whether to use a larger number of intra prediction modes than shown inFIG. 8 may be determined in consideration of at least one of the colorcomponent, the color format component, the size or the shape of theblock, as in the above-described example.

Referring to the drawings to be described later, a method of determiningan intra prediction mode of a current block to be encoded/decoded and amethod of performing intra prediction using the determined intraprediction mode will be described with the drawings.

FIG. 10 is a flowchart briefly illustrating an intra prediction methodaccording to an embodiment of the present invention.

Referring to FIG. 10, an intra prediction mode of a current block may bedetermined at step S1000.

Specifically, the intra prediction mode of the current block may bederived based on a candidate list and an index. Here, the candidate listcontains a plurality of candidates, and a plurality of candidates may bedetermined based on an intra prediction mode of the neighboring blockadjacent to the current block. The neighboring block may include atleast one of blocks positioned at the top, the bottom, the left, theright, or the corner of the current block. The index may specify one ofa plurality of candidates in the candidate list. The candidate specifiedby the index may be set to the intra prediction mode of the currentblock.

An intra prediction mode used for intra prediction in a neighboringblock may be set as a candidate. For example, candidates may be derivedbased on intra prediction modes of the left block, the top block, thebottom left corner neighboring block, the top right corner neighboringblock, and the top left corner neighboring block of the current block.If the neighboring block is encoded by inter prediction, the candidateof the current block may be derived using the intra prediction mode ofthe collocated block of the neighboring block.

Also, an intra prediction mode having directionality similar to that ofthe intra prediction mode of the neighboring block may be set as acandidate. Here, the intra prediction mode having similar directionalitymay be determined by adding or subtracting a predetermined constantvalue to or from the intra prediction mode of the neighboring block. Thepredetermined constant value may be an integer, such as one, two, ormore, and the predetermined constant value may be adaptively determinedaccording to the number of usable intra prediction modes. For example,when the number of usable intra prediction modes is 35, thepredetermined constant value may be set to 1, and when the number ofusable intra prediction modes is 67, the predetermined constant valuemay be set to 2. Furthermore, when the number of usable intra predictionmodes is 131, the predetermined constant value may be set to 4.

The candidate list may further include a default mode. The default modemay include at least one of a planar mode, a DC mode, the vertical mode,the horizontal mode, top right diagonal mode, or top left diagonal mode.The default mode may be adaptively added considering the maximum numberof candidates that can be included in the candidate list of the currentblock.

The maximum number of candidates that can be included in the candidatelist may be three, four, five, six, seven or more. The maximum number ofcandidates that can be included in the candidate list may be a fixedvalue preset in the device for encoding/decoding a video, or may bevariably determined based on a characteristic of the current block. Thecharacteristic may mean a location/size/shape of the block, thenumber/type of intra prediction modes that the block can use, a colortype, a color format, etc. Alternatively, information indicating themaximum number of candidates that can be included in the candidate listmay be signaled separately, and the maximum number of candidates thatcan be included in the candidate list may be variably determined usingthe information. The information indicating the maximum number ofcandidates may be signaled in at least one of a sequence level, apicture level, a slice level, or a block level.

Candidates included in the candidate list may be sorted in a predefinedorder. For example, candidates may be arranged in the candidate list inthe order of the left block, the top block, the bottom left block, thetop right block, and the top left block. Alternatively, the order ofcandidates may be variably determined according to a size or shape ofthe current block. For example, when the current block is a non-squareblock whose height is greater than the width, the intra prediction modeof the top block may be arranged with a higher priority than the intraprediction mode of the left block.

When the extended intra prediction modes and the 35 pre-defined intraprediction modes are selectively used, the intra prediction modes of theneighboring blocks may be transformed into indexes corresponding to theextended intra prediction modes, or into indexes corresponding to the 35intra prediction modes, whereby candidates can be derived. For transformto an index, a pre-defined table may be used, or a scaling operationbased on a predetermined value may be used. Here, the pre-defined tablemay define a mapping relation between different intra prediction modegroups (e.g., extended intra prediction modes and 35 intra predictionmodes).

For example, when the left neighboring block uses the 35 intraprediction modes and the intra prediction mode of the left neighboringblock is 10 (the horizontal mode), it may be transformed into an indexof 16 corresponding to the horizontal mode in the extended intraprediction modes.

Alternatively, when the top neighboring block uses the extended intraprediction modes and the intra prediction mode the top neighboring blockhas an index of 50 (the vertical mode), it may be transformed into anindex of 26 corresponding to the vertical mode in the 35 intraprediction modes.

Based on the above-described method of determining the intra predictionmode, the intra prediction mode may be derived independently for each ofa luma component and a chroma component, or the intra prediction mode ofthe chroma component may be derived depending on the intra predictionmode of the luma component.

Specifically, the intra prediction mode of the chroma component may bedetermined based on the intra prediction mode of the luma component asshown in the following Table 1.

TABLE 1 Intra_chroma_pred_mode IntraPredModeY[xCb][yCb] [xCb][yCb] 0 2610 1 X(0 <= X <= 34) 0 34 0 0 0 0 1 26 34 26 26 26 2 10 10 34 10 10 3 11 1 34 1 4 0 26 10 1 X

In Table 1, intra_chroma_pred_mode means information signaled to specifythe intra prediction mode of the chroma component, and IntraPredModeYindicates the intra prediction mode of the luma component.

When a candidate list is determined, information indicating whether thesame candidate as an intra prediction mode of the current block isincluded in the candidate list may be decoded. When the informationindicates that the same candidate as the intra prediction mode of thecurrent block is included in the candidate list, index information(e.g., MPM_index) indicating any one of candidates may be decoded. Theintra prediction mode of the current block may be set to be the same asan intra prediction mode of a candidate indicated by the indexinformation.

On the other hand, when the information indicates that the samecandidate as the intra prediction mode of the current block is notincluded in the candidate list, remaining intra prediction modeinformation (e.g., rem_intra_mode) specifying any one of remaining intraprediction modes except candidates may be decoded. The intra predictionmode of the current block may be determined based on an intra predictionmode indicated by the remaining intra prediction mode information. Forexample, the current intra prediction mode may be determined bycomparing a candidate with the intra prediction mode indicated by theremaining intra prediction mode. For example, when an intra predictionmode of the candidate is smaller than the intra prediction modeindicated by the remaining intra prediction mode, 1 may be added to theremaining intra prediction mode to derive the intra prediction mode ofthe current block.

Referring to FIG. 10, a reference sample for intra prediction of thecurrent block may be derived at step S1010.

Specifically, a reference sample for intra prediction may be derivedbased on a neighboring sample of the current block. The neighboringsample may be a reconstructed sample of the neighboring block, and thereconstructed sample may be a reconstructed sample before an in-loopfilter is applied or a reconstructed sample after the in-loop filter isapplied.

A neighboring sample reconstructed before the current block may be usedas the reference sample, and a neighboring sample filtered based on apredetermined intra filter may be used as the reference sample.Filtering of neighboring samples using an intra filter may also bereferred to as reference sample smoothing. The intra filter may includeat least one of the first intra filter applied to a plurality ofneighboring samples positioned on the same horizontal line or the secondintra filter applied to a plurality of neighboring samples positioned onthe same vertical line. Depending on the positions of the neighboringsamples, one of the first intra filter and the second intra filter maybe selectively applied, or both intra filters may be applied. At thistime, at least one filter coefficient of the first intra filter or thesecond intra filter may be (1, 2, 1), but is not limited thereto.

The filtering may be adaptively performed based on at least one of theintra prediction mode of the current block or a size of the transformblock for the current block. For example, when the intra prediction modeof the current block is the DC mode, the vertical mode, or thehorizontal mode, filtering may not be performed. When the size of thetransform block is N×M, filtering may not be performed. Here, N and Mmay be the same values or different values, or may be values of 4, 8,16, or more. For example, if the size of the transform block is 4×4,filtering may not be performed. Alternatively, filtering may beselectively performed based on the result of a comparison of apre-defined threshold and the difference between the intra predictionmode of the current block and the vertical mode (or the horizontalmode). For example, when the difference between the intra predictionmode of the current block and the vertical mode is greater than thethreshold, filtering may be performed. The threshold may be defined foreach size of the transform block as shown in Table 2.

TABLE 2 8 × 8 16 × 16 32 × 32 transform transform transform Threshold 71 0

The intra filter may be determined as one of a plurality of intra filtercandidates pre-defined in the device for encoding/decoding a video. Tothis end, a separate index specifying an intra filter of the currentblock among a plurality of intra filter candidates may be signaled.Alternatively, the intra filter may be determined based on at least oneof a size/shape of the current block, a size/shape of the transformblock, the information about the filter strength, or the variation ofsurrounding samples.

The intra prediction on a current coding block may be performed by usinga plurality of reference sample lines. For example, it may be performedby using two or more reference sample lines.

Whether to perform an intra prediction using a plurality of referencesample lines may be determined based on a size/shape of the currentblock, an intra prediction mode, or the like. For example, when an intraprediction mode of a current block is a non-directional intra predictionmode or an intra prediction mode in a specific direction, performing theintra prediction using a plurality of reference sample lines may belimited. Herein, the specific direction may include the verticaldirection, the horizontal direction, or the diagonal direction.

Referring to FIG. 10, intra prediction may be performed using the intraprediction mode of the current block and the reference sample at stepS1020.

That is, the prediction sample of the current block may be obtainedusing the intra prediction mode determined at step S1000 and thereference sample derived at step S1010. When intra prediction isperformed using a plurality of reference sample lines, a predictionsample may be obtained based on a weighted sum of reference samplesbelonging to different reference sample lines. For example, theprediction sample may be derived based on a weighted sum of the firstreference sample belonging to the first reference sample line and thesecond reference sample belonging to the second reference sample line.In this case, the weight applied to the first reference sample and thesecond reference sample may have the same value or may have differentvalues depending on the distance from the prediction target sample. Forexample, a higher weight may be given to a reference sample that isclose to the prediction target sample among the first reference sampleand the second reference sample.

However, in the case of intra prediction, a boundary sample of theneighboring block may be used, and thus quality of the predictionpicture may be decreased. Therefore, a correction process may beperformed on the prediction sample generated through the above-describedprediction process, and will be described in detail with reference toFIG. 11. However, the correction process is not limited to being appliedonly to the intra prediction sample, and may be applied to an interprediction sample or the reconstructed sample.

FIG. 11 is a diagram illustrating a method of correcting a predictionsample of a current block based on differential information ofneighboring samples according to an embodiment of the present invention.

The prediction sample of the current block may be corrected based on thedifferential information of a plurality of neighboring samples for thecurrent block. The correction may be performed on all prediction samplesin the current block, or may be performed on prediction samples inpredetermined partial regions. The partial regions may be one row/columnor a plurality of rows/columns, and these may be preset regions forcorrection in the device for encoding/decoding a video. For example,correction may be performed on a one row/column located at a boundary ofthe current block or may be performed on a plurality of rows/columnsfrom the boundary of the current block. Alternatively, the partialregions may be variably determined based on at least one of a size/shapeof the current block or an intra prediction mode.

The neighboring samples may belong to the neighboring blocks positionedat the top, the left, and the top left corner of the current block. Thenumber of neighboring samples used for correction may be two, three,four, or more. The positions of the neighboring samples may be variablydetermined depending on the position of the prediction sample which isthe correction target in the current block. Alternatively, some of theneighboring samples may have fixed positions regardless of the positionof the prediction sample which is the correction target, and theremaining neighboring samples may have variable positions depending onthe position of the prediction sample which is the correction target.

The differential information of the neighboring samples may mean adifferential sample between the neighboring samples, or may mean a valueobtained by scaling the differential sample by a predetermined constantvalue (e.g., one, two, three, or the like). Here, the predeterminedconstant value may be determined considering the position of theprediction sample which is the correction target, the position of acolumn or a row including the prediction sample which is the correctiontarget, the position of the prediction sample within the column, therow, or the like.

For example, when the intra prediction mode of the current block is thevertical mode, differential samples between the top left neighboringsample p(−1, −1) and neighboring samples p (−1, y) adjacent to the leftboundary of the current block may be used to obtain the final predictionsample as shown in Equation 1.

P′(0,y)=P(0,y)+((p(−1,y)−p(−1,−1))>>1 for y=0 . . . N−1  [Equation 1]

For example, when the intra prediction mode of the current block is thehorizontal mode, differential samples between the top left neighboringsample p(−1, −1) and neighboring samples p(x, −1) adjacent to the topboundary of the current block may be used to obtain the final predictionsample as shown in Equation 1

P′(x,0)=p(x,0)+((p(x,−1)−p(−1,−1))>>1 for x=0 . . . N−1  [Equation 2]

For example, when the intra prediction mode of the current block is thevertical mode, differential samples between the top left neighboringsample p(−1, −1) and neighboring samples p (−1, y) adjacent to the leftboundary of the current block may be used to obtain the final predictionsample as shown in Equation 2. Here, the differential sample may beadded to the prediction sample, or the differential sample may be scaledby a predetermined constant value, and then added to the predictionsample.

The predetermined constant value used in scaling may be determineddifferently depending on the column and/or row. For example, theprediction sample may be corrected as shown in Equation 3 and Equation4.

P′(0,y)=P(0,y)+((p(−1,y)−p(−1,−1))>>1 for y=0 . . . N−1  [Equation 3]

P′(1,y)=P(1,y)+((p(−1,y)−p(−1,−1))>>2 for y=0 . . . N−1  [Equation 4]

For example, when the intra prediction mode of the current block is thehorizontal mode, differential samples between the top left neighboringsample p(−1, −1) and neighboring samples p(x, −1) adjacent to the leftboundary of the current block may be used to obtain the final predictionsample. This is as described above in the horizontal mode. For example,the prediction samples may be corrected as in Equations 5 and 6 below.

P′(x,0)=P(x,0)+((p(x,−1)−p(−1,−1))>>1 for x=0 . . . N−1  [Equation 5]

P′(x,1)=p(x,1)+((p(x,−1)−p(−1,−1))>>2 for x=0 . . . N−1  [Equation 6]

When an intra prediction mode of a current block is a directionalprediction mode, intra prediction of the current block may be performedbased on the directionality of the directional prediction mode. Forexample, Table 3 shows an intra direction parameter intraPredAng fromMode 2 to Mode 34, which is the directional intra prediction modeillustrated in FIG. 8.

TABLE 3 predModeIntra 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16intraPredAng — 32 26 21 17 13 9 5 2 0 −2 −5 −9 −13 −17 −21 predModeIntra18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 intraPredAng −32 −26 −21−17 −13 −9 −5 −2 0 2 5 9 13 17 21 26

In Table 3, 33 directional intra prediction modes have been described byway of example, but more or fewer directional intra prediction modes maybe defined.

An intra direction parameter for a current block may be determined basedon a lookup table that defines a mapping relationship between adirectional intra prediction mode and an intra direction parameter.Alternatively, the intra direction parameter for the current block maybe determined based on the information signaled through the bitstream.

Intra prediction of the current block may be performed using at leastone of the left reference sample or the top reference sample, dependingon the directionality of the directional intra prediction mode. Here,the top reference sample may be a reference sample (e.g., (−1, −1) to(2W−1, −1)) having a y-axis coordinate smaller than the predictiontarget sample (x, 0) included in the top row in the current block, andthe left reference sample may be a reference sample (e.g., (−1, −1) to(−1, 2H−1)) having x-axis coordinates smaller than the prediction targetsample (0, y) included in the leftmost column in the current block.

Depending on a directionality of an intra prediction mode, referencesamples of the current block may be arranged in one dimension.Specifically, when both the top reference sample and the left referencesample should be used for intra prediction of the current block, it isassumed that they are arranged in a line along the vertical orhorizontal direction, and reference samples of each prediction targetsample may be selected.

For example, in the case where the intra direction parameter is negative(e.g., the intra prediction mode corresponding to Mode 11 to Mode 25 inTable 3), the top reference samples and the left reference samples maybe rearranged along the horizontal or vertical direction to form aone-dimensional reference sample group P_ref_1D.

FIGS. 12 and 13 are a diagram illustrating a one-dimensional referencesample group in which reference samples are rearranged in a line.

Whether to rearrange the reference samples in the vertical direction orin the horizontal direction may be determined according to adirectionality of an intra prediction mode. For example, if the intraprediction mode index is between 11 and 18, as in an example shown inFIG. 12, the top reference samples of a current block can be rotatedcounterclockwise to generate a one-dimensional reference sample group inwhich the left reference samples and the top reference samples arearranged in the vertical direction.

On the other hand, if the intra prediction mode index is between 19 and25, as in an example shown in FIG. 13, the left reference samples of thecurrent block may be rotated clockwise to generate a one-dimensionalreference sample group in which the left reference samples and the topreference samples are arranged in the horizontal direction.

If the intra direction parameter of the current block is not negative,intra prediction for the current block may be performed using only theleft reference samples or the top reference samples. Accordingly, forthe intra prediction modes in which the intra direction parameter is notnegative, the one-dimensional reference sample group may be generatedusing only the left reference sample or the top reference samples.

Based on the intra direction parameter, a reference sample determinationindex iIdx for specifying at least one reference sample used to predictthe prediction target sample may be derived. In addition, a weightrelated parameter ifact used to determine a weight applied to eachreference sample based on the intra direction parameter may be derived.For example, Equations 7 and 8 illustrate examples of deriving referencesample determination index and weight related parameter

iIdx=(y+1)*(P _(ang)/32)

if act=[(y+1)*P _(ang)]31  [Equation 7]

As shown in Equation 7, iIdx and ifact are variably determined accordingto the slope of the directional intra prediction mode. In this case, thereference sample specified by iIdx may correspond to an integer pel.

Based on a reference sample determination index, at least one referencesample may be specified for each prediction sample. For example, theposition of the reference sample in the one-dimensional reference samplegroup for predicting the prediction target sample in the current blockmay be specified based on the reference sample determination index.Based on the reference sample at the specified position, a predictionimage (i.e., a prediction sample) for the prediction target sample maybe generated.

Considering an intra prediction mode of a current block, if a predictiontarget sample can be predicted with only one reference sample, theprediction image of the prediction target sample may be generated basedon the reference sample specified by the intra prediction mode of thecurrent block.

For example, when an imaginary angular line according to the angle orthe slope of the intra prediction mode crosses an integer pel (i.e., areference sample at an integer position) the one-dimensional referencesample group, by copying the reference sample at the integer pelposition or considering the position between the reference sample at theinteger pel position and the prediction target sample, the predictionimage of the prediction target sample may be generated. For example, thefollowing Equation 8 illustrates an example of generating the predictionimage P(x, y) for the prediction target sample by copying the referencesample P_ref_1D(x+iIdx+1) in the one-dimensional reference sample groupspecified by the intra prediction mode of the current block.

P(x,y)=P_ref_1D(x+iIdx+1)  [Equation 8]

In consideration of an intra prediction mode of a current block, when itis determined that a prediction target sample is not predicted with onlyone reference sample, a plurality of reference samples may be used toperform prediction on the prediction target sample. Specifically,according to the intra prediction mode of the current block, theprediction target sample may be predicted by performing linearinterpolation or tap filter based interpolation on the reference sampleat a predetermined position and neighboring reference samplesneighboring the reference sample at a predetermined position. The numberof taps of the interpolation filter may be two or more natural numbers.Specifically, the number of taps of the tap filter may be an integer of2, 3, 4, 5, 6, or more, depending on the number of reference samples tobe interpolated.

For example, an imaginary angular line according to the angle of theintra prediction mode or the slope of the intra prediction mode does notcross the integer pel (i.e., the reference sample at the integerposition) in the one-dimensional reference sample group, a predictionimage of a prediction target sample may be generated by interpolating areference sample placed on a corresponding angle line and a referencesample adjacent to the left/right or up/down of the reference sample.For example, the following Equation 9 illustrates an example ofgenerating a prediction sample P(x, y) for a prediction target sample byinterpolating two or more reference samples.

P(x,y)=(32−i _(fact))/32*P_ref_1D(x+iIdx+1)+i_(fact)/32*P_ref_1D(x+iIdx+2)  [Equation 9]

A coefficient of an interpolation filter may be determined based on aweight related parameter ifact. As an example, the coefficient of theinterpolation filter may be determined based on the distance between thefractional pel and the integer pel (i.e., the integer position of eachreference sample) located on an angular line.

The following Equation 10 illustrates a case where a tap number of a tapfilter is 4.

P(x,y)−f(0)*P_ref_1D(x+iIdx−1)+f(1)*P_ref_1D(x−iIdx)−f(2)*P_ref_1D(x+iIdx+1)+f(3)*P_ref_1D(x+iIdx+2)  [Equation10]

When using a multi-tap filter, a sample at a position that does notcorrespond to the left reference sample or the top reference sample maybe replaced with the nearest reference sample at that position. As anexample, in Equation 9, when a sample at the position P_ref_1D(x+iIdx−1) does not correspond to the top reference sample, the samplemay be replaced with a reference sample at the position P_ref_1D(x+idx).Alternatively, when a sample at the P_ref_1D(x+iIdx+2) position does notcorrespond to the top reference sample, the sample may be replaced witha reference sample at the P_ref_1D (x+iIdx+1) position.

The multi-tap filter can be applied to a plurality of reference samplesarranged in a line along the horizontal or vertical direction.Alternatively, the multi-tap filter may be applied to a predeterminedpolygonal shape such as a rectangle. A shape to which the multi-tapfilter is applied may be variably determined according to a size, shape,or intra prediction mode of the current block.

As shown in Equations 8 to 10, generating a prediction sample byinterpolating a reference sample using the directionality of intraprediction may be referred to as an intra prediction sampleinterpolation technique.

In using the intra prediction sample interpolation technique, a largetap number of tap filters does not necessarily guarantee an improvementin prediction accuracy. For example, when a size of the current block isan asymmetric coding unit that one of the height or width issignificantly larger than the other, such as 2×16, or a block of smallsize, such as 4×4, using a tap filter of 4 taps or more may result inexcessive smoothing of the prediction image. Accordingly, a type of tapfilter may be adaptively determined according to a size, shape, or intraprediction mode of the current block. Here, a type of tap filter may beclassified by at least one of a number of taps, filter coefficients,filter strength (strong/weak), or filtering direction. The number offilter taps or the filter coefficient may be variably determinedaccording to the filter strength. In addition, depending on the type ofthe tap filter, an application direction of the tap filter, such ashorizontal interpolation, vertical interpolation, or horizontal andvertical interpolation, may be determined. The application direction ofthe tap filter may be variably set on the basis of lines (rows orcolumns) or samples in the current block.

Specifically, the type of tap filter to be used may be determined basedon the width or height of a current block. As an example, when at leastone of the width or height of the current block is smaller than apredefined value, an intra prediction sample interpolation technique maybe performed by using a 2-tap filter instead of a 4-tap filter. On theother hand, when both the width and height of the current block isgreater than or equal to the predetermined value, the intra predictionsample interpolation technique may be performed using the 4-tap filter.Here, the predefined value may represent a value such as 4, 8, or 16.

Alternatively, the type of tap filter to be used may be determinedaccording to whether the width and height of the current block are thesame. For example, when the width and height of the current block aredifferent values, the intra prediction sample interpolation techniquemay be performed using the 2-tap filter instead of the 4-tap filter. Onthe other hand, when the width and height of the current block have thesame value, the intra prediction sample interpolation technique may beperformed using the 4-tap filter.

Alternatively, the type of tap filter to be used may be determinedaccording to the ratio of the width and the height of the current block.For example, when the ratio of the width (w) to the height (h) of thecurrent block (i.e., w/h or h/w) is less than a predefined threshold,the intra prediction sample interpolation technique may be performedusing the 2-tap filter instead of the 4-tap filter On the other hand,when the ratio of the width and height of the current block is greaterthan or equal to the predefined threshold value, the intra predictionsample interpolation technique may be performed using the 4-tap filter.

Alternatively, the type of tap filter may be determined according to anintra prediction mode, a shape, or a size of the current block. Forexample, when the current block is a 2×16 type coding unit and the intraprediction mode of the current block is an intra prediction modebelonging to the horizontal range, the intra prediction sampleinterpolation technique may be performed using a tap filter having a tapnumber n. On the other hand, when the current block is a 2×16 typecoding unit and the intra prediction mode of the current block is anintra prediction mode belonging to the vertical direction range, theintra prediction sample interpolation technique may be performed using atap filter having a tap number m.

On the other hand, when the current block is a 16×2 type coding unit andthe intra prediction mode of the current block is the intra predictionmode belonging to the horizontal direction range, the intra predictionsample interpolation technique may be performed using a tap filterhaving a tap number n. On the other hand, when the current block is a16×2 type coding unit and the intra prediction mode of the current blockis the intra prediction mode belonging to the vertical direction range,the intra prediction sample interpolation technique may be performedusing a tap filter having a tap number m.

Here, the horizontal range may indicate a predetermined range includingthe intra prediction mode in the horizontal direction, and the verticalrange may indicate a predetermined range including the intra predictionmode in the vertical direction. For example, based on 35 intraprediction modes, the horizontal direction range may indicate an intraprediction mode between modes 11 and 18, and the vertical directionrange may indicate an intra prediction mode between modes 19 and 27.

In addition, n and m are constants greater than 0, and n and m may havedifferent values. Alternatively, n and m may be set to have the samevalue, but at least one of filter coefficients or filter intensities ofthe n tap filter and the m tap filter may be set differently.

When using a directional prediction mode or a DC mode, there may be aproblem in that image quality deterioration occurs at a block boundary.On the other hand, in a planar mode, the image quality deterioration ofthe block boundary is relatively smaller than those prediction modes.

The planar prediction may be performed by generating a first predictionimage in a horizontal direction and a second prediction image in avertical direction by using reference samples, and then performingweighted prediction for the first prediction image and the secondprediction image.

Herein, the first prediction image may be generated based on referencesamples adjacent to the current block placed in a horizontal directionof a prediction target sample. As an example, the first prediction imagemay be generated based on a weighted sum of reference samples placed ina horizontal direction of the prediction target sample. In this case, aweight applied to each reference sample may be determined inconsideration of a distance to the prediction target sample or a size ofthe current block. Samples placed in a horizontal direction may comprisea left reference sample on the same horizontal line as the predictiontarget sample (that is, a left reference sample having the same ycoordinate as the prediction target sample) and a right reference sampleon the same horizontal line as the prediction target sample (that is, aright reference sample having the same y coordinate as the predictiontarget sample). In this case, the right reference sample may be derivedfrom a top reference sample of the current block. For example, the rightreference sample may be derived by copying a value of the top referencesample placed on the same vertical line as the right reference sample,or may be derived as a weighted sum or an average value of a pluralityof top reference samples. Herein, the top reference sample placed on thesame vertical line as the right reference sample may include a referencesample adjacent to a top right corner of the current block (that is, thetop reference sample having the same x coordinate as the right referencesample). Alternatively, depending on a shape, a size of the currentblock, or a position of the prediction target sample, a position of thetop reference sample used to derive the right reference sample may bedetermined differently.

A second prediction image may be generated based on reference samplesadjacent to the current block placed in a vertical direction of aprediction target sample. As an example, the second prediction image maybe generated based on a weighted sum of reference samples placed in thevertical direction of the prediction target sample. In this case, aweight applied to each reference sample may be determined inconsideration of a distance to the prediction target sample or a size ofthe current block. Samples placed in the vertical direction may comprisea top reference sample on the same vertical line as the predictiontarget sample (that is, a top reference sample having the same xcoordinate as the prediction target sample) and a bottom referencesample on the same vertical line as the prediction target sample (thatis, a bottom reference sample having the same x coordinate as theprediction target sample). In this case, the bottom reference sample maybe derived from a left reference sample of the current block. Forexample, the bottom reference sample may be derived by copying a valueof the left reference sample placed on the same horizontal line as thebottom reference sample, or may be derived as a weighted sum or anaverage value of a plurality of left reference samples. Herein, the leftreference sample placed on the same horizontal line as the bottomreference sample may include a reference sample adjacent to a bottomleft corner of the current block (that is, the left reference samplehaving the same y coordinate as the bottom reference sample).Alternatively, depending on a shape, a size of the current block, or aposition of the prediction target sample, a position of the topreference sample used to derive the bottom reference sample may bedetermined differently.

Alternatively, both the left reference sample and the top referencesample may be used to derive at least one of the right reference sampleor the bottom reference sample.

As an example, a weighted sum or an average of the top reference sampleand the left reference sample of the current block may be determined asa value of at least one of the right reference sample or the bottomreference sample.

Alternatively, the bottom left reference sample and the top rightreference sample may be used to derive a bottom right reference sampleadjacent to a bottom right corner of the current block, and then thederived bottom right reference sample may be used to derive the rightreference sample and the bottom reference sample. The bottom rightreference sample may be derived based on a weighted sum or an average ofthe top right reference sample and the left reference sample of thecurrent block. In this case, weights applied to the top right referencesample and the left reference sample may have the same value or may bedetermined based on a width/height of the current block.

Once the bottom right reference sample is determined, the rightreference sample may be derived by interpolating the bottom rightreference sample and the top right reference sample, and the bottomreference sample may be derived by interpolating the bottom rightreference sample and the bottom left reference sample. In this case,coefficients of an interpolation filter may be determined based on asize of the current block, a shape of the current block, a distance tothe bottom right reference sample, a distance to the top right referencesample, or a distance to the bottom left reference sample.

In order to derive the right reference sample or the left referencesample, a reference sample of a fixed position may be used, or areference sample that is adaptively selected according to a position ofa prediction target sample may be used. For example, the right referencesample may be derived by using the top right reference sampleirrespective of the position of the prediction target sample, or may bederived by using a left reference sample selected according to theposition of the prediction target sample (e.g., reference sample havingthe same y-axis coordinate as the prediction target sample) or a topreference sample selected according to the position of the predictiontarget sample (e.g., reference sample having the same x-axis coordinateas the prediction target sample). Alternatively, the bottom referencesample may be derived using the bottom left reference sample regardlessof the position of the prediction target sample, or may be derived usinga left reference sample selected according to the position of theprediction target sample (e.g., reference sample having the same y-axiscoordinate as the prediction target sample) or a top reference sampleselected according to the position of the prediction target sample(e.g., reference sample having the same x-axis coordinate as theprediction target sample).

FIGS. 14A and 14B are diagrams illustrating an example of deriving aright reference sample or a bottom reference sample using a plurality ofreference samples. Assume that the current block is a block having asize of W×H.

Referring to FIG. 14A, first, based on a weighted sum or an averagevalue of a top right reference sample P(W, −1) and a bottom left sampleP(−1, H) of the current block, a bottom right reference samples P(W, H)may be generated. In this case, weights applied to the top rightreference sample and the left reference sample may be set equally ordetermined based on a width W and a height H of the current block. Forexample, when the current block is non-square, a weight applied to thetop right reference sample may be determined as W/(W+H), and a weightapplied to the bottom left reference sample may be determined asH/(W+H).

Furthermore, a right reference sample P(W, y) for a prediction targetsample (x, y) may be generated based on the bottom right referencesample P(W, H) and the top right reference sample P(W, −1). For example,the right prediction sample P(W, y) may be calculated as a weighted sumor an average value of the bottom right reference sample P(W, H) and thetop right reference sample P(W, −1). In addition, a bottom referencesample P(x, H) for the prediction target sample (x, y) may be generatedbased on the bottom right reference sample P(W, H) and the bottom leftreference sample P(−1, H). For example, the bottom reference sample P(x,H) may be calculated as a weighted sum or an average value of the bottomright reference sample P(W, H) and the left reference sample P(−1, H).

As shown in FIG. 14B, when the right reference sample and the bottomreference sample are generated, a first prediction sample P_(h)(x, y)and a second prediction sample P_(v)(x, y) of the prediction targetsample may be generated by using the generated reference samples. Inthis case, the first prediction sample P_(h)(x, y) may be generatedbased on a weighted sum of the left reference sample P(−1, y) and theright reference sample P(W, y), and the second prediction sampleP_(v)(x, y) may be generated based on a weighted sum of the topreference sample P(x, −1) and the bottom reference sample P(x, H).

FIGS. 15 and 16 are diagrams for explaining determining a rightreference sample and a bottom reference sample for a non-square blockaccording to an embodiment of the present invention.

As in an example shown in FIG. 15, when the current block is anon-square block of (N/2)×N, a right reference sample may be derivedbased on a top right reference sample P(N/2, −1), and a bottom referencesample may be derived based on a bottom left reference sample P(−1, N).

Alternatively, the right reference sample or the bottom reference samplemay be derived based on at least one of a weighted sum, an average, aminimum, or a maximum value of the top right reference sample P(N/2, −1)and the bottom left reference sample P(−1, N). For example, the rightreference sample may be derived based on a weighted sum or an average ofP(N/2, −1) and P(−1, N), or may be derived by interpolating a bottomright reference sample and the top right reference sample. Afterderiving the bottom right reference sample P(N/2, N) based on P(N/2, −1)and P(−1, N). Alternatively, the bottom reference sample may be derivedbased on a weighted sum or an average of P(N/2, −1) and P(−1, N), or maybe derived by interpolating the bottom right reference sample and thebottom left reference sample after deriving the bottom right referencesample P(N/2, N) based on P(N/2, −1) and P(−1, N).

On the other hand, as in an example shown in FIG. 16, when the currentblock is a non-square block of N×(N/2), a right reference sample may bederived based on a top right reference sample P(N, −1), a bottomreference sample may be derived based on a bottom left reference sampleP(−1, N/2).

Alternatively, a right reference sample or a bottom reference sample maybe derived based on at least one of a weighted sum, an average, aminimum, or a maximum value of a he top left reference sample P(N, −1)and a bottom left reference sample P(−1, N/2). For example, the rightreference sample may be derived based on a weighted sum or an average ofP(N, −1) and P(−1, N/2), or may be derived by interpolating a bottomright reference sample and the top right reference sample after derivingthe bottom right reference sample P(N, N/2) based on P(N, −1) and P(−1,N/2). Alternatively, the bottom reference sample may be derived based ona weighted sum or an average of P(N, −1) and P (−1, N/2), or may bederived by interpolating the bottom right reference sample and thebottom left reference sample after deriving the bottom right referencesample P(N, N/2) based on P (N, −1) and P (−1, N/2).

In an example described with reference to FIGS. 14A and 14B to 16, abottom reference sample may be derived based on at least one of a bottomleft reference sample of the current block placed on the same horizontalline as the bottom reference sample or a top right reference sample ofthe current block placed on the same vertical line as the rightreference sample, and a right reference sample may be derived based onat least one of a top right reference sample of the current block placedon the same vertical line as the right reference sample or a bottom leftreference sample of the current block placed on the same horizontal lineas a bottom reference sample. Unlike the example as described, the rightreference sample or the left reference sample may be derived based on atleast one of a top center reference sample or a left center referencesample. For example, after deriving a bottom center sample using the topcenter sample and the bottom left reference sample, bottom samples maybe generated by interpolation or extrapolation of the bottom centersample and the bottom left sample. In addition, after deriving a rightcenter sample by using the left center sample and the right top sample,bottom samples may be generated by interpolation or extrapolation of theright center sample and the top right sample.

A location of reference samples used to generate a first predictionimage and a second prediction image may be determined differentlyaccording to a size or a shape of a current block. For example,depending on the size or the shape of the current block, a position of atop reference sample or a left reference sample used to derive a rightreference sample or a bottom reference sample may be determineddifferently.

As an example, when the current block is a square block of N×N size, aright reference sample may be derived based on a top right referencesample P(N, −1), while a bottom reference sample may be derived based ona bottom left reference sample P(−1, N). Alternatively, when the currentblock is a square block of N×N size, a right reference sample and abottom reference sample may be derived at least one of a weighted sum,an average, a minimum, or a maximum value of the top right referencesample P(N, −1) and the bottom left reference sample P(−1, N).

On the other hand, when the current block is a non-square block of N×2/Nsize, a bottom center reference sample P(N/2, N/2) may be derived basedon a top center reference sample P(N/2, −1) and a bottom left referencesample P(−1, N/2), and then bottom reference samples may be derivedbased on the derived bottom center reference sample. For example, thebottom reference samples may be derived through interpolation orextrapolation of the bottom center reference sample and the bottom leftreference sample. Alternatively, when the current block is a non-squareblock of N/2×N size, a right center reference samples P(N/2, N/2) may bederived based on a top right reference sample P(N/2, −1) and a leftcenter reference sample P(−1, N/2), and then right reference samples maybe derived based on the derived right center reference sample.

For example, the right reference samples may be derived throughinterpolation or extrapolation of the right center reference sample andthe top right reference sample.

A first prediction image may be calculated based on weighted predictionof reference samples placed on the same horizontal line as a predictiontarget sample. Also, a second prediction image may be calculated basedon weighted prediction of reference samples placed on the same verticalline as the prediction target sample.

In addition to the above-described example, the first prediction imageor the second prediction image may be generated using an average value,a minimum value, or a maximum value of reference samples.

Depending on whether a prediction target sample is included in apredetermined region of the current block, a size or a shape of thecurrent block, or the like, a method of deriving a reference sample maybe set differently, or a method of deriving a first prediction image ora second prediction may be set differently. Specifically, according to aposition of a prediction target sample, the number of reference samplesor a position of a reference sample used to derive a right or a bottomreference sample is determined differently, or a weight or the number ofreference samples used to derive a first prediction image or a secondprediction image may be set differently.

For example, a right reference sample used for generating a firstprediction image of prediction target samples included in apredetermined region may be derived using only a top reference sample,and a right reference sample used for generating a first predictionimage of a prediction target samples included outside the predeterminedregion may be derived based on a weighted sum or an average of a topreference sample and a left reference sample.

For example, as in an example shown in FIG. 15, when the current blockis a non-square block whose a height is greater than a width, a rightreference sample of a prediction target sample at a position (x, y)included in a predetermined region in the current block may be derivedfrom P(N/2, −1). For example, the right reference sample of theprediction target sample included in the predetermined region may begenerated by copying a value of the reference sample P(N/2, −1). On theother hand, a right reference sample of a prediction target sample at aposition (x′, y′) included outside the predetermined region in thecurrent block may be derived based on a weighted sum or an average valueof P(N/2, −1) and P (−1, N). For example, the right reference sample ofthe prediction target sample included outside the predetermined regionmay be generated through interpolation of a bottom right referencesample P(N/2, N) derived based on P(N/2, −1) and P(−1, N) and the topright reference sample P (N/2, −1).

Alternatively, for example, as in an example shown in FIG. 16, when thecurrent block is a non-square block whose a width is greater than aheight, a bottom reference sample of a prediction target sample at aposition (x, y) included in a predetermined region in the current blockmay be derived from P(−1, N/2). For example, the bottom reference sampleof the prediction target sample included in the predetermined region maybe generated by copying a value of the reference sample P(−1, N/2). Onthe other hand, a bottom reference sample of a he prediction targetsample at a position (x′, y′) included outside the predetermined regionin the current block may be derived based on a weighted sum or anaverage value of P(N, −1) and P (−1, N/2). For example, the bottomreference sample of the prediction target sample included outside thepredetermined region may be generated through interpolation of a bottomright reference sample P(N, N/2) derived based on P(N, −1) and P(−1,N/2) and the bottom left reference sample P (−1, N/2).

As another example, a first prediction image or a second predictionimage for prediction target samples included in a predetermined regionmay be generated based on a weighted sum of reference samples, and afirst prediction image or a second prediction image for predictiontarget samples outside the predetermined region may be generated usingan average value, a minimum value, or a maximum value of referencesamples, or using only one having a predefined position among referencesamples. For example, as in an example shown in FIG. 15, when a currentblock is a non-square block whose a height is greater than a width, afirst prediction image for a prediction target sample at the position(x, y) included in a predetermined region in the current block may begenerated using only one of right reference sample P(N/2, y) derivedfrom P (N/2, −1) and left reference sample at a position P(−1, y). Onthe other hand, a first prediction image for a prediction target sampleat a position (x′, y′) not included in the predetermined region may begenerated based on a weighted sum or an average of a right referencesamples P(N/2, y′) derived from P(N/2, −1) and a reference sample at aposition of P(−1, y′).

Alternatively, as in an example shown in FIG. 16, when a current blockis a non-square block whose a width is greater than a height, a secondprediction image for a prediction target sample at a position (x, y)included in a predetermined region in the current block may be generatedusing only one of a bottom reference sample P(x, N/2) derived from P(−1,N/2) or a top reference sample at a position P(x, −1). On the otherhand, a second prediction image for a prediction target sample at aposition (x′, y′) not included in the predetermined region may begenerated based on a weighted sum or an average of a bottom referencesamples P (x′, N/2) derived from P(−1, N/2) and a reference sample at ahe position of P (−1, y′).

In the above-described embodiment, a predetermined region may be atleast one a sample line adjacent to a boundary of the current block orone of remaining region except for the sample line. Herein, the boundaryof the current block may include at least one of a left boundary, aright boundary, a top boundary, or a bottom boundary. In addition, thenumber or location of boundaries used to define the predetermined regionmay be set differently according to a shape of the current block.Alternatively, the predetermined region may be in a shape of a blockadjoins one corner of the current block. In this case, a size and ashape of the predetermined region may be determined based on at leastone of a size or a shape of the current block.

In a planar mode, a final prediction image may be derived based on aweighted sum, an average, a minimum value, or a maximum value of a firstprediction image and a second prediction image.

For example, Equation 11 below illustrates an example of generating thefinal prediction image P based on a weighted sum of the first predictionimage P_(h) and the second prediction image P.

P(x,y)=(w*P _(h)(x,y)+(1−w)*P _(p)(x,y)+N)>>(log 2(N)+1  [Equation 11]

In Equation 11, a prediction weight w may be different according to ashape, a size of the current block, or a position of a prediction targetsample.

As an example, the prediction weight w may be derived in considerationof a width of the current block, a height of the current block, awidth-to-height ratio, or the like. When the current block is anon-square block whose a width is greater than a height, w may be setthat a higher weight is applied to the first prediction image. On theother hand, when the current block is a non-square block whose a heightis greater than a width, w may be set that a higher weight is applied tothe second prediction image.

As an example, when the current block is square, the prediction weight wmay have a value of ½. On the other hand, when the current block is anon-square block (e.g., (N/2)×N) whose a height is greater than a width,the prediction weight w may be set to ¼. In addition, when the currentblock is a non-square block (e.g., N×(N/2)) whose a width is greaterthan a height, the prediction weight w may be set to ¾.

In addition to a planar mode, intra prediction based on a DC mode or adirectional intra prediction mode also can be performed by usingreference samples other than left reference samples and top referencesamples. In a following embodiment, the left reference sample and thetop reference sample will be referred to as a first reference sample,and reference samples other than the left reference sample and the topreference sample will be referred to as a second reference sample. As anexample, the second reference sample may include a right referencesample and/or a bottom reference sample of the current block. Herein,bottom reference samples may refer to reference samples having a y-axiscoordinate greater than a prediction target sample of a bottom row inthe current block, and right reference samples may refer to referencesamples having an x-axis coordinate greater than a prediction targetsample of a rightmost column in the current block.

Whether to perform intra prediction using a second reference sample maybe determined based on at least one of a size, a shape or an intraprediction mode of the current block, or a position of a predictiontarget sample. For example, it may be determined whether to performintra prediction using the second reference sample based on whether theintra prediction mode of the current block is a vertical mode, ahorizontal mode, or a diagonal mode. Alternatively, intra prediction fora prediction target sample included in a predetermined region in thecurrent block is performed by using the second reference sample, whileintra prediction for a prediction target sample not included in thepredetermined region in the current block is performed by using a firstreference sample.

Alternatively, information indicating whether the second referencesample is used may be signaled through the bitstream. The informationmay be a 1-bit flag, an index used to determine an intra prediction modeof the current block, or the like.

Alternatively, whether to use the second reference sample may bedetermined based on whether the second reference sample is used in aneighboring block of the current block.

A second reference sample may be generated based on a first referencesample. As an example, second reference samples may be configured bychanging an order of first reference samples, or a second referencesamples may be derived using a first reference sample at a specificposition.

FIG. 17 is a diagram for explaining an example of deriving a secondreference sample using a first reference sample.

First, a bottom right reference sample P(W, H) derived based on a topright reference sample r(W, −1) and a bottom left reference sample r(−1,H) of the current block may be derived. In detail, the bottom rightreference sample may be derived through a weighted sum or an averagevalue of the top right reference sample and the bottom left referencesample. Equation 12 shows an example of deriving the bottom rightreference sample.

$\begin{matrix}{{P\left( {W,H} \right)} = \frac{{W \times {r\left( {W,{- 1}} \right)}} + {H \times {r\left( {{- 1},H} \right)}}}{W + H}} & \left\lbrack {{Equation}\mspace{14mu} 12} \right\rbrack\end{matrix}$

As shown in Equation 12, the bottom right reference sample may becalculated based on a weighted sum between the top right referencesample and the bottom left reference sample. In this case, a weightapplied to the top right reference sample and the bottom left referencesample may be determined according to a width and a height of thecurrent block. For example, when the current block is square, the sameweight is applied to the top right reference sample and the bottom leftreference sample. In contrast, when the current block is non-square,different weights may be applied to the top right reference sample andthe bottom left reference sample. However, the weight setting methodshown in Equation 12 is merely an example of the present invention, andthe present invention is not limited thereto. In addition to an exampleshown in Equation 12, the weight may be determined based on at least oneof a size, a shape or an intra prediction mode of the current block,availability of a reference sample, availability of a neighboring block,whether a neighboring block is encoded in an intra prediction mode, oran intra prediction mode of a neighboring block.

A right reference sample may be derived based on the top right referencesample and the bottom right reference sample. For example, the rightreference sample may be obtained by interpolating the top rightreference sample and the bottom right reference sample. Equation 13below shows an example of deriving the right reference sample.

$\begin{matrix}{{P_{r}\left( {W,y} \right)} = \frac{{\left( {H - 1 - y} \right) \times {r\left( {W,{- 1}} \right)}} + {\left( {y + 1} \right) \times {P\left( {W,H} \right)}}}{H}} & \left\lbrack {{Equation}\mspace{14mu} 13} \right\rbrack\end{matrix}$

As shown in Equation 13, the right reference sample P_(r)(W, y) (where yis an integer between 0 and CU height (cu_height)), may be obtained byweighted prediction of the top right reference sample r(W, −1) and thebottom right reference sample P(W, H). In this case, a weight applied tothe top right reference sample and the bottom right reference sample maybe determined based on at least one of a width, a height of the currentblock, or a position of the right reference sample. For example, as inan example shown in Equation 13, a weight of (H−1−y)/H is applied to thetop right reference sample, while a weight of (y+1)/H is applied to thebottom right reference sample. However, a weight setting method shown inEquation 13 is merely an example of the present invention, and thepresent invention is not limited thereto. In addition to an exampleshown in Equation 13, the weight may be determined based on at least oneof a size, a shape or an intra prediction mode of the current block,availability of a reference sample, availability of a neighboring block,whether a neighboring block is encoded in an intra prediction mode, oran intra prediction mode of a neighboring block.

A bottom reference sample may be derived based on the bottom leftreference sample and the bottom right reference sample. As an example,the bottom reference sample may be obtained by interpolating the bottomleft reference sample and the bottom right reference sample. Equation 14shows an example of deriving the bottom reference sample.

$\begin{matrix}{{P_{b}\left( {x,H} \right)} = \frac{{\left( {W - 1 - x} \right) \times {r\left( {{- 1},H} \right)}} + {\left( {x + 1} \right) \times {P\left( {W,H} \right)}}}{W}} & \left\lbrack {{Equation}\mspace{14mu} 14} \right\rbrack\end{matrix}$

As shown in Equation 14, the bottom reference sample P_(b)(x, H) (wherex is an integer between 0 and CU width (cu_width)), may be obtained byweighted prediction of the bottom left reference sample r(−1, H) and thebottom right reference sample P(W, H). In this case, a weight applied tothe bottom left reference sample and the bottom right reference samplemay be determined based on at least one of a width, a height of thecurrent block, or a position of the bottom reference sample. Forexample, as in an example shown in Equation 14, a weight of (W−1−x)/W isapplied to the bottom left reference sample, while a weight of (x+1)/His applied to the bottom right reference sample. However, the weightsetting method shown in Equation 14 is only an example of the presentinvention, and the present invention is not limited thereto. In additionto an example shown in equation 14, the weight may be determined basedon at least one of a size, a shape or an intra prediction mode of thecurrent block, availability of a reference sample, availability of aneighboring block, whether a neighboring block is encoded in an intraprediction mode, or an intra prediction mode of a neighboring block.

When the current block is non-square, a right reference sample and abottom reference sample may be derived based on an example describedabove with reference to FIGS. 15 and 16.

As in the above-described example, a second reference sample such as aright reference sample and a bottom reference sample may be derivedusing a first reference samples of a fixed position such as a top rightreference sample and a bottom left reference sample. Unlike the exampledescribed above, a second reference sample may be derived using a firstreference sample at a position different from a top right referencesample and/or a top left reference sample. For example, a rightreference sample and a bottom reference sample may be derived by using afirst reference sample such as a top center reference sample of thecurrent block or a left center sample of the current block.

Alternatively, a first reference sample used to derive a secondreference sample may be determined according to an intra prediction modeof the current block. As an example, a right reference sample and/or abottom reference sample may be derived based on a he left referencesample and/or a top reference sample specified by a directionality ofthe intra prediction mode of the current block.

Alternatively, a second reference sample may be determined using aplurality of left reference samples and/or a plurality of top referencesamples. For example, at least one of a right reference sample, a bottomreference sample, or a right bottom reference sample may be generatedbased on a weighted sum, an average value, a maximum value, or a minimumvalue of a plurality of left reference samples, or a weighted sum, anaverage value, a maximum value or a minimum value of a plurality of topreference samples.

Alternatively, a second reference sample may be generated by copying afirst reference sample. In this case, the first reference sample used togenerate the second reference sample may have a fixed position or may beadaptively determined according to a size, a shape or an intraprediction mode or the current block, or position of the secondreference sample.

In an above example, although illustrated as having W bottom referencesamples and H right reference samples, a larger number of bottomreference samples and/or right reference samples may be derived. Forexample, bottom reference samples may be derived up to the same verticalline as the rightmost top reference sample r(2W−1, −1), or rightreference samples may be derived up to the same horizontal line as thelowest left reference sample r(−1, 2H−1).

In this case, a bottom reference sample having an x coordinate greaterthan W may be generated by extrapolating a bottom left reference sampleand a bottom right reference sample, or may be generated byinterpolating the bottom right reference sample P (W, H) and a rightmostbottom reference sample P(2W−1, H). The rightmost bottom referencesample may be generated by copying a rightmost top reference sampler(2W−1, −1), or may be generated through a weighted sum operationbetween the rightmost top reference sample and the bottom left referencesample. A right reference sample having a y coordinate greater than Hmay be generated by extrapolating the top right reference sample and thebottom right reference sample, or may be generated by interpolation thebottom right reference samples P(W, H) and a lowest right referencesamples P (W, 2H−1). In this case, the lowest right reference sample maybe generated by copying a lowest left reference sample r (−1, 2H−1) ormay be generated by a weighted sum operation between the lowest leftreference sample and the top left reference sample.

A first reference samples may be arranged in one dimension to generate afirst one-dimensional reference sample group, and a second referencesamples may be arranged in one dimension to generate a secondone-dimensional reference sample group. In this case, the firstone-dimensional reference sample group may be configured to include notonly the first reference samples but also at least one or more of thesecond reference samples, and the second one-dimensional referencesample group may be configured to include not only the second referencesamples but also at least one or more of the first reference samples.

FIGS. 18A and 18B are diagrams illustrating reference samples thatconstitute a one-dimensional reference sample group.

As in an example shown in FIG. 18A, the first one-dimensional referencesample group may be composed of left reference samples and top referencesamples of a current block.

On the other hand, as in an example shown in FIG. 18B, the secondone-dimensional reference sample group may be configured to furtherinclude not only the right reference samples and the bottom referencesamples of the current block, but also some left reference samples andsome top reference samples.

That is, a bottom left reference sample r(−1, H) and left referencesamples having a y-axis coordinate greater than the bottom leftreference sample among left reference samples may be included in boththe first one-dimensional reference sample group and the secondone-dimensional reference sample group. Also, a top reference samplesr(W, −1) and top reference samples having an x-axis coordinate greaterthan the top right reference sample among top reference samples may beincluded in both the first one-dimensional reference sample group andthe second one-dimensional reference sample group.

Alternatively, based on at least one of a size, a shape, or an intraprediction mode of the current block, a part of first reference samplesmay be included only in the first one-dimensional reference samplegroup, or a part of first reference samples may be included only in thesecond one-dimensional reference sample group. In addition to aconfiguration of a one-dimensional reference sample group, anarrangement order of reference samples constituting the one-dimensionalreference sample group also can be variably determined based on at leastone of a size, a shape, or an intra prediction mode of the currentblock.

For convenience of description, in the embodiment described below, areference sample group including left reference samples and topreference samples of the current block will be referred to as a firstreference sample group (e.g., a first one-dimensional reference samplegroup), a reference sample group including right reference samples andbottom reference samples of the current block will be referred to as asecond reference sample group (e.g., a second one-dimensional referencesample group). For example, the first reference sample group and thesecond reference sample group may be classified according to whetherright reference samples and bottom reference samples are included. Inaddition, in order to perform intra prediction of a prediction targetsample, a reference sample selected from the first reference samplegroup will be referred to as a first basic reference sample, and areference sample selected from the second reference sample group will bereferred to as a second basic reference sample.

Intra prediction of the current block may be performed using at leastone of a first reference sample group or a second reference samplegroup. For example, a prediction value of a prediction target sample inthe current block may be obtained based on at least one of a first basicreference sample selected from the first reference sample group or asecond basic reference sample selected from the second reference samplegroup. In this case, the first basic reference sample and/or the secondbasic reference sample may be determined based on at least one of ashape, a size, or an intra prediction mode of the current block. Forexample, when the intra prediction mode of the current block isdetermined, the first basic reference sample for the prediction targetsample may be specified according to a direction of the determined intraprediction mode, and the second basic reference samples for theprediction target sample may be specified according to a reversedirection of the determined intra prediction mode

Alternatively, a position of the second basic reference sample may bedetermined based on a position of the first basic reference sample, or aposition of the first basic reference sample may be determined based ona position of the second basic reference sample. For example, the secondbasic reference sample having the same x coordinate or the same ycoordinate as the first basic reference sample may be selected, or thesecond basic reference sample having a position derived by adding anoffset to the x coordinate or the y coordinate of the first basicreference sample may be selected. Herein, the offset may have a fixedvalue or may be adaptively determined according to a size, a shape, oran intra prediction mode of the current block.

Alternatively, a position of the first basic reference sample and/or thesecond basic reference sample may be determined based on a position of aprediction target sample. For example, the first basic reference sampleand/or the second basic reference sample having the same x coordinate orthe same y coordinate as the prediction target sample may be selected,or the first basic reference sample and/or the second basic referencesample having a position obtained by adding an offset to the xcoordinate or the y coordinate of the prediction target sample may beselected. Herein, the offset may have a fixed value or may be adaptivelydetermined according to a size, a shape, or an intra prediction mode ofthe current block.

A prediction value of a prediction target sample may be generated basedon at least one of a first prediction image based on the first basicreference sample or a second prediction image based on the second basicreference sample. In this case, the first prediction image may begenerated based on the above description through Equation 8 to Equation10 described above.

The second prediction image may be generated by interpolating or copyingthe second basic reference sample specified according to a slope of anintra prediction mode of the current block. For example, Equation 15 isa diagram illustrating an example of deriving the second predictionimage by copying the second basic reference sample.

P ₂(x,y)=P_2nd_1D(x+iIdx+1+f)  [Equation 15]

In Equation 15, P₂ (X, y) represents the second prediction image, andP_2nd_1D (x+iIdx+1+f) represents the second basic reference sample.

When only one second basic reference sample cannot express a slope of anintra prediction mode of the current block, the second prediction imagemay be generated by interpolating a plurality of second basic referencesamples. Specifically, when an imaginary angular line following a slopeand/or angle of an intra prediction mode does not pass an integer pel(i.e., a reference sample of an integer position), the second predictionimage may be obtained by interpolating second reference samples adjacentto a left and a right or an up and a down of the angular line. Forexample, Equation 16 illustrates an example of obtaining the secondprediction image by interpolating the second reference samples.

${\mspace{641mu} {\left\lbrack {{Equation}\mspace{14mu} 16} \right\rbrack {{P_{2}\left( {x,y} \right)} = {\frac{\left( {32 - i_{fact}} \right)}{32} \times}}}\quad}{\quad{{{P\_}2{nd\_}1{D\left( {x + {ildx} + 1 + f} \right)}} + {\frac{i_{fact}}{32} \times {P\_}2{nd\_}1{D\left( {x + {ildx} + 2 + f} \right)}}}}$

A coefficient of an interpolation filter may be determined based on aweight related parameter i_(fact). As an example, the coefficient of theinterpolation filter may be determined based on a distance between afractional pel and an integer pel (i.e., an integer position of eachreference sample) located on an angular line.

In Equation 16, it is illustrated that a interpolation filter having atap number of 2 is used, but an interpolation filter having a tap numbergreater than 2 can be used instead.

A final prediction image of a prediction target sample may be obtainedbased on at least one of a first prediction image or a second predictionimage. For example, the first prediction image may be determined as thefinal prediction image of a prediction target sample, or the secondprediction image may be determined as the final prediction image of theprediction target sample. Alternatively, the final prediction image ofthe prediction target sample may be determined based on a weighted sumor an average of the first prediction image and the second predictionimage. Equation 17 shows an example of obtaining the final predictionsample based on a weighting operation of the first prediction image andthe second prediction image.

P(x,y)=w(x,y)×P ₁(x,y)+(1−w(x,y))×P ₂(x,y)  [Equation 17]

In Equation 17, P₁ (x, y) represents a first prediction image, and P₂(x,y) represents a second prediction image. In addition, w(x, y) representsa weight applied to the first prediction image.

Weights assigned to the first prediction image and the second predictionimage may be determined based on at least one of a location of aprediction target sample, or a size, a shape, or an intra predictionmode of the current block. For example, Equation 18 shows an example inwhich the weights are determined according to a size of the currentblock and a position of the prediction target sample.

$\begin{matrix}{{P\left( {x,y} \right)} = {\quad\frac{\begin{matrix}{{\left( {\left( {W + H} \right) - \left( {x + y} \right)} \right) \times {P_{1}\left( {x,y} \right)}} +} \\{\left( {x + y} \right) \times {P_{2}\left( {x,y} \right)}}\end{matrix}}{W + H}}} & \left\lbrack {{Equation}\mspace{14mu} 18} \right\rbrack\end{matrix}$

In Equation 18, W and H represent a width and a height of the currentblock, respectively, and (x, y) represents a coordinate of a predictiontarget sample.

As in an example shown in Equation 18, as a prediction target sample iscloser to a top left corner of the current block, a weight to be appliedto a first predicted image may be increased. In addition, as aprediction target sample is closer to a bottom right corner of thecurrent block, a weight applied to a second prediction image may beincreased.

Alternatively, a weight may be derived from a neighboring block of thecurrent block. Herein, the neighboring block of the current block mayinclude at least one of a top neighboring block, a left neighboringblock, or a neighboring block adjacent to a corner of the current block(e.g., a top left neighboring block, a top right neighboring block, or abottom left neighboring block).

Alternatively, information for determining a weight may be signaled viaa bitstream. The information may indicate a weight value applied to afirst prediction image or a second prediction image, or may indicate aweight difference value between the current block and a neighboringblock.

As in the above-described example, obtaining a final prediction imagethrough a weighted sum operation between a first prediction image and asecond prediction image may be referred to as bi-directional intraprediction (or bi-intra prediction).

Bi-intra prediction may be applied only for a part of regions in thecurrent block. In this case, a region to which the bi-intra predictionis applied may be pre-defined in the encoder and the decoder. Forexample, the bi-intra prediction may be applied to a predetermined sized(e.g., 4×4) block adjacent to a bottom right corner of the currentblock. Alternatively, a region to which the bi-intra prediction isapplied may be determined adaptively according to a size, a shape, or anintra prediction mode of the current block. Alternatively, informationfor determining a region to which the bi-intra prediction is applied(e.g., information indicating a size or a location of the area) may besignaled through the bitstream.

FIG. 19 is an example of a region to which bi-directional intraprediction is applied.

In a region to which bi-directional intra prediction is applied, a finalprediction sample may be obtained by weighted prediction of a firstprediction image and a second prediction image. On the other hand, afirst prediction image or a second prediction image may be determined asa final prediction sample in a region where bi-directional intraprediction is not applied.

In the above example, it has been described that bi-directional intraprediction is performed using a first basic reference sample selectedfrom a first sample group and a second basic reference sample selectedfrom a second sample group. Unlike the example as described, it is alsopossible to select a plurality of reference samples from a first samplegroup to perform bi-directional intra prediction, or to select aplurality of reference samples from a second sample group to performbi-directional intra prediction. For example, when an intra predictionmode of the current block has a top right diagonal direction or a bottomleft diagonal direction, bi-directional intra prediction may beperformed by selecting a top reference sample and a left referencesample from a first sample group. That is, a final prediction sample ofthe current block may be obtained by weighted prediction of a firstreference image obtained based on the top reference sample and a secondreference image obtained based on the bottom reference sample.

Alternatively, according to an intra prediction mode, bi-directionalintra prediction may be performed by selecting a right reference sampleand a bottom reference sample from a second sample group.

Bi-directional intra prediction may be defined as an independent intraprediction mode. For example, a total of 2N+2 intra prediction modes maybe defined by defining N directional prediction modes and Nbi-directional intra prediction modes corresponding to the N directionalprediction modes. For example, by adding a bi-directional intraprediction mode to an intra prediction mode illustrated in FIG. 8, atotal of 68 intra prediction modes (that is, two non-directional intraprediction modes, directional intra prediction modes, and 33bi-directional intra prediction modes) may be defined. Of course, it isalso possible to use more or less than 33 directional intra predictionmodes or to use more or less than 33 bi-directional intra predictionmodes.

Alternatively, after determining an intra prediction mode of the currentblock, it may be determined whether to use the determined intraprediction mode to switch to a bi-directional prediction mode. Forexample, when an intra prediction mode of the current block isdetermined, information about whether to use the determined intraprediction mode as a bi-directional intra prediction mode may bedecoded. The information may be a 1-bit flag (e.g., bi_intra_flag), butis not limited thereto. A value of bi_intra_flag of 0 indicates thatdirectional intra prediction is performed, and a value of bi_intra_flagof 1 indicates that bi-directional intra prediction is performed. Thatis, when the value of bi_intra_flag is 0, a first prediction image isdetermined as a final prediction sample of the current block, whereaswhen the value of bi_intra_flag is 1, weighted prediction of a firstprediction image and a second prediction image may be determined as afinal prediction sample of the current block.

Alternatively, depending on whether a neighboring block adjacent to thecurrent block used a bi-directional intra prediction mode, it may bedetermined whether the current block uses a bi-directional intraprediction mode. For example, when an intra prediction mode of thecurrent block is the same as a candidate (i.e., MPM candidate) derivedbased on an intra prediction mode of the neighboring block, whether touse a bi-directional intra prediction mode for the current block may bedetermined in the same as whether a bi-directional intra prediction modewas used in the neighboring block.

Alternatively, whether to perform bi-directional intra prediction may bedetermined based on a size and/or a shape of the current block. Forexample, bi-directional intra prediction is allowed for only a block of32×32 or more. Accordingly, bi-directional intra prediction may not beapplied when a size of the current block is smaller than 32×32, whereasbi-directional intra prediction may be applied when a size of thecurrent block is 32×32.

As another example, bi-directional intra prediction may be allowed onlyfor a square block, or bi-directional intra prediction may be allowedonly for a non-square block.

Alternatively, bi-directional intra prediction may be applied only for apart of directional intra prediction modes. For example, FIG. 20 is anexample of identifying and indicating a directional prediction mode inwhich bi-directional intra prediction is allowed. As shown in theexample illustrated in FIG. 20, bi-directional intra prediction isallowed only for a part of intra prediction modes between a horizontaldirection and a vertical direction. In this case, bi-directional intraprediction may be performed by default when an intra prediction mode isselected within the range, or it may be determined whether to performbi-directional intra prediction mode based on at least one ofinformation parsed through the bitstream, or a size or a shape of thecurrent block when an intra prediction mode within the range isselected.

An intra prediction mode in which bi-directional intra prediction isallowed is not limited to the example shown in FIG. 20. An intraprediction mode in which bi-directional intra prediction is allowed maybe predefined in the encoder and the decoder, or may be adaptivelydetermined according to a size and/or a shape of the current block.Alternatively, information for determining an intra prediction mode inwhich bi-directional intra prediction is allowed may be signaled througha bitstream.

FIG. 21 is a flowchart illustrating an intra prediction method of thecurrent block based on a bi-directional intra prediction mode accordingto the present invention.

First, it may be determined whether bi-directional intra prediction isapplied to the current block (S2110). Whether bi-directional intraprediction is applied to the current block may be determined based oninformation parsed from the bitstream, a shape, a size, or an intraprediction mode of the current block.

As an example, after determining an intra prediction mode of the currentblock based on a candidate list and an index, whether bi-directionalintra prediction on the current block is applied may be determined basedon a size or a shape of the current block, or information parsed from abitstream (e.g., bi_pred_flag). Alternatively, whether bi-directionalintra prediction is applied to the current block may be determined basedon whether the intra prediction mode of the current block is adirectional prediction mode to which bi-directional intra prediction isapplied.

Thereafter, a reference sample of the current block may be derived(S2120). First, first reference samples adjacent to a left and a top ofthe current block may be derived, and second reference samples adjacentto a right and a bottom of the current block may be further derived whenbi-directional intra prediction is applied to the current block (S2130).

In addition, when bi-directional intra prediction is not applied to thecurrent block, according to the intra prediction mode of the currentblock, a first prediction image may be generated based on at least onebasic reference sample among the first reference samples (S2140). Inthis case, the first prediction image may be determined as a finalprediction sample of the current block.

On the other hand, when bi-directional intra prediction is applied tothe current block, in addition to the first prediction image, a secondprediction image may be generated based on at least one basic referencesample of the second reference samples (S2150). The first basicreference sample and the second basic reference sample may be determinedbased on a directionality of the intra prediction mode, and may bedetermined based on a size or a shape of the current block, or aposition of another basic reference sample. When the first predictionimage and the second prediction image are obtained, a final predictionsample of the current block may be obtained by weighted prediction ofthe first prediction image and the second prediction image.

Although the above-described embodiments are described based on a seriesof steps or flowcharts, this does not limit the time-series order of theinvention and may be performed simultaneously or in a different order asnecessary. In addition, in the above-described embodiment, eachcomponent (e.g., a unit, a module, or the like.) constituting the blockdiagram may be implemented as a hardware device or software, and aplurality of components may be combined to be implemented as onehardware device or software. The above-described embodiments may beimplemented in the form of program instructions that may be executed byvarious computer components, and may be recorded in a computer-readablerecording medium. The computer-readable recording medium may include aprogram instruction, a data file, a data structure, etc. alone or incombination. Examples of computer-readable recording media includemagnetic media such as a hard disk, a floppy disk and a magnetic tape,an optical recording media such as a CD-ROM, a DVD, and amagneto-optical media such as a floptical disk, and hardware devicesspecifically configured to store and execute a program instruction, suchas a ROM, a RAM, a flash memory, and the like. The hardware device maybe configured to operate as one or more software modules to perform theprocess according to the invention, and vice versa.

INDUSTRIAL APPLICABILITY

The present invention can be applied to an electronic device capable ofencoding/decoding an image.

1. A method of decoding a video, the method comprising: determiningwhether bi-directional intra prediction is applied to a current block;deriving a reference sample of the current block; and when thebi-directional intra prediction is applied to the current block,obtaining a prediction sample of the current block based on a firstreference sample and a second reference sample specified by an intraprediction mode of the current block.
 2. The method of claim 1, whereinthe first reference sample is a left or top reference sample of thecurrent block, and the second reference sample is a right or bottomreference sample of the current block.
 3. The method of claim 2, whereinthe right reference sample is generated by interpolating a bottom rightreference sample and a top right reference sample, and the bottomreference sample is generated by interpolating the bottom rightreference sample and a bottom left reference sample.
 4. The method ofclaim 1, wherein the first reference sample is selected by applying theintra prediction mode of the current block in a forward direction, andthe second reference sample is selected by applying the intra predictionmode of the current block in a reverse direction.
 5. The method of claim1, wherein the prediction sample is obtained based on a weighted sumoperation of a first prediction sample obtained based on the firstreference sample and a second prediction sample obtained based on thesecond reference sample.
 6. The method of claim 5, wherein a weightapplied to each of the first prediction sample and the second predictionsample is determined based on at least one of a location of a predictiontarget sample, a size, a shape, or the intra prediction mode of thecurrent block.
 7. The method of claim 1, wherein the bi-directionalintra prediction is applied only to a predetermined region in thecurrent block.
 8. The method of claim 1, wherein determining whether thebi-directional intra prediction is applied to the current blockcomprises: determining whether the intra prediction mode of the currentblock is a directional intra prediction mode; and decoding informationindicating whether the directional intra prediction mode is used as thebi-directional intra prediction mode.
 9. The method of claim 1, whereinwhether the bi-directional intra prediction is applied to the currentblock is determined based on whether bi-directional intra prediction isapplied to a neighboring block neighboring the current block.
 10. Themethod of claim 1, wherein, when the intra prediction mode of thecurrent block is a directional intra prediction mode within apredetermined range, it is determined that the bi-directional intraprediction is applied to the current block.
 11. A method of encoding avideo, the method comprising: determining whether bi-directional intraprediction is applied to a current block; deriving a reference sample ofthe current block; and when the bi-directional intra prediction isapplied to the current block, obtaining a prediction sample of thecurrent block based on a first reference sample and a second referencesample specified by an intra prediction mode of the current block. 12.The method of claim 11, wherein the first reference sample is selectedby applying the intra prediction mode of the current block in a forwarddirection, and the second reference sample is selected by applying theintra prediction mode of the current block in a reverse direction. 13.The method of claim 11, wherein the prediction sample is obtained basedon a weighted sum operation of a first prediction sample obtained basedon the first reference sample and a second prediction sample obtainedbased on the second reference sample.
 14. An apparatus for decoding avideo, the apparatus comprising: an intra prediction unit to determinewhether bi-directional intra prediction is applied to a current block,derive a reference sample of the current block, and when thebi-directional intra prediction is applied to the current block, basedon a first reference sample and a second reference sample specified byan intra prediction mode of the current block, obtain a predictionsample of the current block.
 15. An apparatus for encoding a video, theapparatus comprising: an intra prediction unit to determine whetherbi-directional intra prediction is applied to a current block, derive areference sample of the current block, and when the bi-directional intraprediction is applied to the current block, based on a first referencesample and a second reference sample specified by an intra predictionmode of the current block, obtain a prediction sample of the currentblock.